Exemple #1
0
 def test_reload_expectNewValue(self):
     m = hotswapping.create_descriptor_from_fs(self.module_path)
     self.assertEqual(3, hotswapping.load(m).FOOBAR)
     hotswapping.unload(m)
     m = hotswapping.renew(
         m, hotswapping.NewerSemanticVersion(check_existence=True),
         hotswapping.MaxAge(-1))
     self.assertEqual(39, hotswapping.load(m).FOOBAR)
     hotswapping.unload(m)
Exemple #2
0
 def test_noNewerVersion_expectNotRenewed(self):
     module_path = os.path.abspath(
         os.path.join(os.path.dirname(__file__), 'testdata', '2.1.0',
                      'foobar.py'))
     m = hotswapping.create_descriptor_from_fs(module_path)
     self.assertFalse(m.deprecated)
     new_m = hotswapping.renew(m, self.search_rule, self.timer_rule)
     self.assertFalse(new_m)
     self.assertFalse(m.deprecated)
Exemple #3
0
    def test_expectIrregularModuleFileIgnored(self):
        """
        gracefully handle the situation when a module's __file__ field has non-string value
        """
        m = hotswapping.create_descriptor_from_fs(self.module_path)
        hotswapping.load(m)
        self.assertTrue(__import__('wicked'))

        # should not throw even though module wicked has irregular __file__ field
        hotswapping.unload(m)
Exemple #4
0
 def test_load_unload_expectSymbol(self):
     m = hotswapping.create_descriptor_from_fs(self.module_path)
     mod_ = hotswapping.load(m)
     self.assertEqual(3, mod_.FOOBAR)
     self.assertEqual(3, hotswapping.unload(m))
Exemple #5
0
 def test_expectModuleDescriptor(self):
     m = hotswapping.create_descriptor_from_fs(self.module_path)
     self.assertTrue(m)
Exemple #6
0
 def test_givenDirectoryPath_expectNothingImported(self):
     self.assertFalse(
         hotswapping.create_descriptor_from_fs(
             os.path.dirname(self.module_path)))
Exemple #7
0
 def test_nonExistingPath_expectNothingImported(self):
     self.assertFalse(hotswapping.create_descriptor_from_fs(''))