示例#1
0
 def regen(**kwargs):
     """Create a test module, import and return it"""
     outf = open('test_version_information.py', 'wb')
     try:
         builder = PythonVersionInfoBuilder(wt.branch,
                                            working_tree=wt,
                                            **kwargs)
         builder.generate(outf)
     finally:
         outf.close()
     module_info = imp.find_module('test_version_information',
                                   [os.getcwdu()])
     tvi = imp.load_module('tvi', *module_info)
     # Make sure the module isn't cached
     sys.modules.pop('tvi', None)
     sys.modules.pop('test_version_information', None)
     # Delete the compiled versions, because we are generating
     # a new file fast enough that python doesn't detect it
     # needs to recompile, and using sleep() just makes the
     # test slow
     if os.path.exists('test_version_information.pyc'):
         os.remove('test_version_information.pyc')
     if os.path.exists('test_version_information.pyo'):
         os.remove('test_version_information.pyo')
     return tvi
示例#2
0
    def test_python_dotted_revno(self):
        wt = self.create_tree_with_dotted_revno()

        sio = StringIO()
        builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt)
        builder.generate(sio)
        val = sio.getvalue()
        self.assertContainsRe(val, "'revno': '1.1.1'")
示例#3
0
    def test_python_dotted_revno(self):
        wt = self.create_tree_with_dotted_revno()

        sio = StringIO()
        builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt)
        builder.generate(sio)
        val = sio.getvalue()
        self.assertContainsRe(val, "'revno': '1.1.1'")
示例#4
0
    def test_python_null(self):
        wt = self.make_branch_and_tree('branch')

        sio = StringIO()
        builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt)
        builder.generate(sio)
        val = sio.getvalue()
        self.assertContainsRe(val, "'revision_id': None")
        self.assertContainsRe(val, "'revno': '0'")
        self.assertNotContainsString(val, '\n\n\n\n')
示例#5
0
    def test_python_null(self):
        wt = self.make_branch_and_tree('branch')

        sio = StringIO()
        builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt)
        builder.generate(sio)
        val = sio.getvalue()
        self.assertContainsRe(val, "'revision_id': None")
        self.assertContainsRe(val, "'revno': '0'")
        self.assertNotContainsString(val, '\n\n\n\n')
示例#6
0
 def regen(**kwargs):
     """Create a test module, import and return it"""
     outf = open('test_version_information.py', 'wb')
     try:
         builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt,
                                            **kwargs)
         builder.generate(outf)
     finally:
         outf.close()
     module_info = imp.find_module('test_version_information',
                                   [os.getcwdu()])
     tvi = imp.load_module('tvi', *module_info)
     # Make sure the module isn't cached
     sys.modules.pop('tvi', None)
     sys.modules.pop('test_version_information', None)
     # Delete the compiled versions, because we are generating
     # a new file fast enough that python doesn't detect it
     # needs to recompile, and using sleep() just makes the
     # test slow
     if os.path.exists('test_version_information.pyc'):
         os.remove('test_version_information.pyc')
     if os.path.exists('test_version_information.pyo'):
         os.remove('test_version_information.pyo')
     return tvi