~ruby/pythoscope/better-exception-handling

« back to all changes in this revision

Viewing changes to test/test_generator.py

  • Committer: Michal Kwiatkowski
  • Date: 2008-10-11 17:48:37 UTC
  • Revision ID: constant.beta@gmail.com-20081011174837-q2wc8eyw9x73f5gi
Generator generates proper tests for Python generators with incomplete inputs or outputs (part of the 'Handle Python generators' blueprint).

Show diffs side-by-side

added added

removed removed

Lines of Context:
447
447
        assert_contains(result, "super_generator = SuperGenerator()")
448
448
        assert_contains(result, "self.assertEqual(['one', 'two'], list(super_generator.degenerate(what='strings')))")
449
449
 
 
450
    def test_generates_assert_equal_stub_for_generator_functions_with_unpickable_inputs(self):
 
451
        objects = [GeneratorWithYields('call_twice', {'x': lambda: 1}, [1, 1])]
 
452
 
 
453
        result = generate_single_test_module(objects=objects)
 
454
 
 
455
        assert_contains(result, "def test_call_twice_yields_1_then_1_for_function(self):")
 
456
        assert_contains(result, "# self.assertEqual([1, 1], list(call_twice(x=<TODO: function>)))")
 
457
 
 
458
    def test_generates_assert_equal_types_for_generator_functions_with_unpickable_outputs(self):
 
459
        objects = [GeneratorWithYields('lambdify', {'x': 1}, [lambda: 1, lambda: 2])]
 
460
 
 
461
        result = generate_single_test_module(objects=objects)
 
462
 
 
463
        assert_contains(result, "def test_lambdify_yields_function_then_function_for_1(self):")
 
464
        assert_contains(result, "self.assertEqual([types.FunctionType, types.FunctionType], map(type, lambdify(x=1)))")
 
465
 
450
466
class TestGeneratorWithTestDirectoryAsFile:
451
467
    def setUp(self):
452
468
        self.project = TestableProject()