Exemple #1
0
    def _setUp(self):
        tempdir = self.useFixture(fixtures.TempDir()).path
        self.path = os.path.join(tempdir, '{}.py'.format(self.name))
        with open(self.path, 'w') as f:
            f.write(self.code)

        # preserve state
        old_sys_path = sys.path
        sys.path = [tempdir] + old_sys_path
        _service.clear_metadata()

        self.addCleanup(clean_up_module, self.name, old_sys_path)
Exemple #2
0
def clean_up_module(name, old_syspath=None):
    sys.modules.pop(text_to_native_str(name))
    _service.clear_metadata()

    if old_syspath is not None:
        sys.path = old_syspath
Exemple #3
0
 def _setUp(self):
     _service.clear_metadata()
     self.addCleanup(clean_up_module, self.name)
Exemple #4
0
def tearDownModule():
    if sys.path[-1] == 'examples/django_app':
        sys.path = sys.path[:-1]
    os.environ.pop('DJANGO_SETTINGS_MODULE')
    clear_metadata()