(self)
| 418 | print('value={}'.format(value), file=fl) |
| 419 | |
| 420 | def test_simple(self): |
| 421 | pkgname = 'foo' |
| 422 | dirname_0 = self.create_init(pkgname) |
| 423 | dirname_1 = self.create_init(pkgname) |
| 424 | self.create_submodule(dirname_0, pkgname, 'bar', 0) |
| 425 | self.create_submodule(dirname_1, pkgname, 'baz', 1) |
| 426 | import foo.bar |
| 427 | import foo.baz |
| 428 | # Ensure we read the expected values |
| 429 | self.assertEqual(foo.bar.value, 0) |
| 430 | self.assertEqual(foo.baz.value, 1) |
| 431 | |
| 432 | # Ensure the path is set up correctly |
| 433 | self.assertEqual(sorted(foo.__path__), |
| 434 | sorted([os.path.join(dirname_0, pkgname), |
| 435 | os.path.join(dirname_1, pkgname)])) |
| 436 | |
| 437 | # Cleanup |
| 438 | shutil.rmtree(dirname_0) |
| 439 | shutil.rmtree(dirname_1) |
| 440 | del sys.path[0] |
| 441 | del sys.path[0] |
| 442 | del sys.modules['foo'] |
| 443 | del sys.modules['foo.bar'] |
| 444 | del sys.modules['foo.baz'] |
| 445 | |
| 446 | |
| 447 | # Another awful testing hack to be cleaned up once the test_runpy |
nothing calls this directly
no test coverage detected