Esempio n. 1
0
 def test_duplicates_included(self):
     exporter = export_pot._PotExporter(StringIO(), True)
     context = export_pot._ModuleContext("mod.py", 1)
     exporter.poentry_in_context(context, "Common line.")
     context.lineno = 3
     exporter.poentry_in_context(context, "Common line.")
     self.assertEqual(2, exporter.outf.getvalue().count("Common line."))
Esempio n. 2
0
 def test_duplicates_included(self):
     exporter = export_pot._PotExporter(StringIO(), True)
     context = export_pot._ModuleContext("mod.py", 1)
     exporter.poentry_in_context(context, "Common line.")
     context.lineno = 3
     exporter.poentry_in_context(context, "Common line.")
     self.assertEqual(2, exporter.outf.getvalue().count("Common line."))
Esempio n. 3
0
 def test_registry_option_title_context_string(self):
     s = "Grounded!"
     context = export_pot._ModuleContext("practice.py", 3, ({}, {s: 144}))
     opt = option.RegistryOption.from_kwargs("concrete", title=s)
     self.assertContainsString(
         self.pot_from_option(opt, context), "#: practice.py:144\n"
         "# title of 'concrete' test\n")
Esempio n. 4
0
 def test_registry_option_title_context_string(self):
     s = "Grounded!"
     context = export_pot._ModuleContext("practice.py", 3, ({}, {s: 144}))
     opt = option.RegistryOption.from_kwargs("concrete", title=s)
     self.assertContainsString(self.pot_from_option(opt, context),
         "#: practice.py:144\n"
         "# title of 'concrete' test\n")
Esempio n. 5
0
 def test_option_context_string(self):
     s = "Literally."
     context = export_pot._ModuleContext("local.py", 3, ({}, {s: 17}))
     opt = option.Option("example", help=s)
     self.assertContainsString(
         self.pot_from_option(opt, context), "#: local.py:17\n"
         "# help of 'example' test\n")
Esempio n. 6
0
 def pot_from_option(self, opt, context=None, note="test"):
     sio = StringIO()
     exporter = export_pot._PotExporter(sio)
     if context is None:
         context = export_pot._ModuleContext("nowhere", 0)
     export_pot._write_option(exporter, context, opt, note)
     return sio.getvalue()
Esempio n. 7
0
 def test_option_context_string(self):
     s = "Literally."
     context = export_pot._ModuleContext("local.py", 3, ({}, {s: 17}))
     opt = option.Option("example", help=s)
     self.assertContainsString(self.pot_from_option(opt, context),
         "#: local.py:17\n"
         "# help of 'example' test\n")
Esempio n. 8
0
 def pot_from_option(self, opt, context=None, note="test"):
     sio = StringIO()
     exporter = export_pot._PotExporter(sio)
     if context is None:
         context = export_pot._ModuleContext("nowhere", 0)
     export_pot._write_option(exporter, context, opt, note)
     return sio.getvalue()
Esempio n. 9
0
 def test_from_string_missing(self):
     """When string has no lineno the old context details are returned"""
     path = "str_missing.py"
     context = export_pot._ModuleContext(path, 4, ({}, {"line\n": 21}))
     context1 = context.from_string("line\n")
     context2A = context.from_string("not there")
     self.check_context(context2A, path, 4)
     context2B = context1.from_string("not there")
     self.check_context(context2B, path, 21)
     self.assertContainsRe(self.get_log(), "String 'not there' not found")
Esempio n. 10
0
 def test_from_string_missing(self):
     """When string has no lineno the old context details are returned"""
     path = "str_missing.py"
     context = export_pot._ModuleContext(path, 4, ({}, {"line\n": 21}))
     context1 = context.from_string("line\n")
     context2A = context.from_string("not there")
     self.check_context(context2A, path, 4)
     context2B = context1.from_string("not there")
     self.check_context(context2B, path, 21)
     self.assertContainsRe(self.get_log(), "String 'not there' not found")
Esempio n. 11
0
 def test_from_class_missing(self):
     """When class has no lineno the old context details are returned"""
     path = "cls_missing.py"
     class A(object): pass
     class M(object): pass
     context = export_pot._ModuleContext(path, 3, ({"A": 15}, {}))
     contextA = context.from_class(A)
     contextM1 = context.from_class(M)
     self.check_context(contextM1, path, 3)
     contextM2 = contextA.from_class(M)
     self.check_context(contextM2, path, 15)
     self.assertContainsRe(self.get_log(), "Definition of <.*M'> not found")
Esempio n. 12
0
 def test_from_string(self):
     """New context returned with lineno updated from string"""
     path = "str.py"
     str_lines = {"one": 14, "two": 42}
     context = export_pot._ModuleContext(path, _source_info=({}, str_lines))
     context1 = context.from_string("one")
     self.check_context(context1, path, 14)
     context2A = context.from_string("two")
     self.check_context(context2A, path, 42)
     context2B = context1.from_string("two")
     self.check_context(context2B, path, 42)
     self.check_context(context, path, 1)
     self.assertEquals("", self.get_log())
Esempio n. 13
0
 def test_from_string(self):
     """New context returned with lineno updated from string"""
     path = "str.py"
     str_lines = {"one": 14, "two": 42}
     context = export_pot._ModuleContext(path, _source_info=({}, str_lines))
     context1 = context.from_string("one")
     self.check_context(context1, path, 14)
     context2A = context.from_string("two")
     self.check_context(context2A, path, 42)
     context2B = context1.from_string("two")
     self.check_context(context2B, path, 42)
     self.check_context(context, path, 1)
     self.assertEqual("", self.get_log())
Esempio n. 14
0
 def test_from_class(self):
     """New context returned with lineno updated from class"""
     path = "cls.py"
     class A(object): pass
     class B(object): pass
     cls_lines = {"A": 5, "B": 7}
     context = export_pot._ModuleContext(path, _source_info=(cls_lines, {}))
     contextA = context.from_class(A)
     self.check_context(contextA, path, 5)
     contextB1 = context.from_class(B)
     self.check_context(contextB1, path, 7)
     contextB2 = contextA.from_class(B)
     self.check_context(contextB2, path, 7)
     self.check_context(context, path, 1)
     self.assertEquals("", self.get_log())
Esempio n. 15
0
    def test_from_class_missing(self):
        """When class has no lineno the old context details are returned"""
        path = "cls_missing.py"

        class A(object):
            pass

        class M(object):
            pass

        context = export_pot._ModuleContext(path, 3, ({"A": 15}, {}))
        contextA = context.from_class(A)
        contextM1 = context.from_class(M)
        self.check_context(contextM1, path, 3)
        contextM2 = contextA.from_class(M)
        self.check_context(contextM2, path, 15)
        self.assertContainsRe(self.get_log(), "Definition of <.*M'> not found")
Esempio n. 16
0
    def test_from_class(self):
        """New context returned with lineno updated from class"""
        path = "cls.py"

        class A(object):
            pass

        class B(object):
            pass

        cls_lines = {"A": 5, "B": 7}
        context = export_pot._ModuleContext(path, _source_info=(cls_lines, {}))
        contextA = context.from_class(A)
        self.check_context(contextA, path, 5)
        contextB1 = context.from_class(B)
        self.check_context(contextB1, path, 7)
        contextB2 = contextA.from_class(B)
        self.check_context(contextB2, path, 7)
        self.check_context(context, path, 1)
        self.assertEqual("", self.get_log())
Esempio n. 17
0
 def test_registry_option_title_context_missing(self):
     context = export_pot._ModuleContext("theory.py", 3)
     opt = option.RegistryOption.from_kwargs("abstract", title="Unfounded!")
     self.assertContainsString(self.pot_from_option(opt, context),
         "#: theory.py:3\n"
         "# title of 'abstract' test\n")
Esempio n. 18
0
 def test_option_context_missing(self):
     context = export_pot._ModuleContext("remote.py", 3)
     opt = option.Option("metaphor", help="Not a literal in the source.")
     self.assertContainsString(self.pot_from_option(opt, context),
         "#: remote.py:3\n"
         "# help of 'metaphor' test\n")
Esempio n. 19
0
 def test_option_context_missing(self):
     context = export_pot._ModuleContext("remote.py", 3)
     opt = option.Option("metaphor", help="Not a literal in the source.")
     self.assertContainsString(
         self.pot_from_option(opt, context), "#: remote.py:3\n"
         "# help of 'metaphor' test\n")
Esempio n. 20
0
 def test_registry_option_title_context_missing(self):
     context = export_pot._ModuleContext("theory.py", 3)
     opt = option.RegistryOption.from_kwargs("abstract", title="Unfounded!")
     self.assertContainsString(
         self.pot_from_option(opt, context), "#: theory.py:3\n"
         "# title of 'abstract' test\n")
Esempio n. 21
0
 def test___init__(self):
     context = export_pot._ModuleContext("one.py")
     self.check_context(context, "one.py", 1)
     context = export_pot._ModuleContext("two.py", 5)
     self.check_context(context, "two.py", 5)
Esempio n. 22
0
 def test___init__(self):
     context = export_pot._ModuleContext("one.py")
     self.check_context(context, "one.py", 1)
     context = export_pot._ModuleContext("two.py", 5)
     self.check_context(context, "two.py", 5)