def setUp(self): self.modules = sys.modules.copy() self.tempdir = tempfile.mkdtemp(prefix='haas-tests-') klass = builder.Class( 'TestSomething', (builder.Method('test_method'), ), ) expected_klass = builder.Class( 'TestExpected', (builder.Method('test_expected'), ), ) module1 = builder.Module('test_some.thing.py', (klass, )) module2 = builder.Module('test_something_else.py', (klass, )) module3 = builder.Module('test_another_one.py', (expected_klass, )) subpackage = builder.Package( 'subpackage', ( builder.Package('package1', (module1, )), builder.Package('packa.ge2', (module2, )), builder.Package('package3', (module3, )), ), ) package = builder.Package('package', (subpackage, )) fixture = builder.Package('fixture', (package, )) fixture.create(self.tempdir)
def setUp(self): self.modules = sys.modules.copy() self.tempdir = tempfile.mkdtemp(prefix='haas-tests-') klass = builder.Class( 'TestSomething', (builder.Method('test_method'), ), ) module1 = builder.Module('test_something.py', (klass, )) module2 = builder.Module('test_something_else.py', (klass, )) subpackage = builder.Package( 'subpackage', ( builder.Package('package1', (module1, )), builder.Package('package2', (module2, )), ), ) package = builder.Package('package', (subpackage, )) fixture = builder.Package('fixture', (package, )) fixture.create(self.tempdir) module_path = os.path.join(self.tempdir, fixture.name, package.name, subpackage.name, module1.name) with open(module_path, 'w') as fh: fh.write('import haas.i_dont_exist\n')
def setUp(self): self.modules = sys.modules.copy() self.tempdir = tempfile.mkdtemp(prefix='haas-tests-') klass = builder.Class( 'TestSomething', (builder.Method('test_method'), ), ) module = builder.Module('.#test_module.py', (klass, )) module = builder.Module('test_module.py', (klass, )) fixture = builder.Package( 'testing_package', (module, ), ) fixture.create(self.tempdir)
def setUp(self): self.modules = sys.modules.copy() self.tempdir = tempfile.mkdtemp(prefix='haas-tests-') text = builder.RawText('ImportError', 'from . import i_dont_exist') klass = builder.Class( 'TestSomething', (builder.Method('test_method'), ), ) module = builder.Module('test_importerror.py', (klass, )) fixture = builder.Directory( 'testing_package', ( builder.Module('__init__.py', (text, )), module, ), ) fixture.create(self.tempdir)
def setUp(self): self.modules = sys.modules.copy() self.tempdir = tempfile.mkdtemp(prefix='haas-tests-') text = builder.RawText('ImportError', 'import haas.i_dont_exist') klass = builder.Class( 'TestSomething', (builder.Method('test_method'), ), ) module = builder.Module('test_importerror.py', ( text, klass, )) package = builder.Package('package', (module, )) fixture = builder.Package('fixture', (package, )) fixture.create(self.tempdir)
def setUp(self): self.modules = sys.modules.copy() self.tempdir = tempfile.mkdtemp(prefix='haas-tests-') text = builder.RawText('RuntimeError', 'raise RuntimeError("failed")') klass = builder.Class( 'TestSomething', (builder.Method('test_method'), ), ) module = builder.Module('test_importerror.py', ( text, klass, )) fixture = builder.Package( 'testing_package', (module, ), ) fixture.create(self.tempdir)