def test_check_restructuredtext(self):
        # let's see if it detects broken rest in description
        broken_rest = 'title\n===\n\ntest'
        pkg_info, dist = self.create_dist(description=broken_rest)
        cmd = check(dist)
        cmd.check_restructuredtext()
        self.assertEqual(len(self.get_logs()), 1)

        # let's see if we have an error with strict=1
        metadata = {
            'home_page': 'xxx',
            'author': 'xxx',
            'author_email': 'xxx',
            'name': 'xxx',
            'version': '1.2',
            'description': broken_rest
        }
        self.assertRaises(PackagingSetupError,
                          self._run,
                          metadata,
                          strict=True,
                          all=True)
        self.loghandler.flush()

        # and non-broken rest, including a non-ASCII character to test #12114
        dist = self.create_dist(description='title\n=====\n\ntest \u00df')[1]
        cmd = check(dist)
        cmd.check_restructuredtext()
        self.assertEqual(self.get_logs(), [])
예제 #2
0
    def test_check_restructuredtext(self):
        # let's see if it detects broken rest in long_description
        broken_rest = 'title\n===\n\ntest'
        pkg_info, dist = self.create_dist(description=broken_rest)
        cmd = check(dist)
        cmd.check_restructuredtext()
        self.assertEqual(len(cmd._warnings), 1)

        pkg_info, dist = self.create_dist(description='title\n=====\n\ntest')
        cmd = check(dist)
        cmd.check_restructuredtext()
        self.assertEqual(len(cmd._warnings), 0)
예제 #3
0
 def test_check_hooks(self):
     pkg_info, dist = self.create_dist()
     dist.command_options['install'] = {
         'pre_hook': ('file', {"a": 'some.nonextistant.hook.ghrrraarrhll'}),
     }
     cmd = check(dist)
     cmd.check_hooks_resolvable()
     self.assertEqual(len(cmd._warnings), 1)
예제 #4
0
 def test_warn(self):
     _, dist = self.create_dist()
     cmd = check(dist)
     self.assertEqual(self.get_logs(), [])
     cmd.warn('hello')
     self.assertEqual(self.get_logs(), ['check: hello'])
     cmd.warn('hello %s', 'world')
     self.assertEqual(self.get_logs(), ['check: hello world'])
     cmd.warn('hello %s %s', 'beautiful', 'world')
     self.assertEqual(self.get_logs(), ['check: hello beautiful world'])
 def test_warn(self):
     _, dist = self.create_dist()
     cmd = check(dist)
     self.assertEqual(self.get_logs(), [])
     cmd.warn('hello')
     self.assertEqual(self.get_logs(), ['check: hello'])
     cmd.warn('hello %s', 'world')
     self.assertEqual(self.get_logs(), ['check: hello world'])
     cmd.warn('hello %s %s', 'beautiful', 'world')
     self.assertEqual(self.get_logs(), ['check: hello beautiful world'])
 def test_check_hooks(self):
     pkg_info, dist = self.create_dist()
     dist.command_options['install_dist'] = {
         'pre_hook': ('file', {
             "a": 'some.nonextistant.hook.ghrrraarrhll'
         }),
     }
     cmd = check(dist)
     cmd.check_hooks_resolvable()
     self.assertEqual(len(self.get_logs()), 1)
예제 #7
0
 def _run(self, metadata=None, **options):
     if metadata is None:
         metadata = {}
     pkg_info, dist = self.create_dist(**metadata)
     cmd = check(dist)
     cmd.initialize_options()
     for name, value in options.items():
         setattr(cmd, name, value)
     cmd.ensure_finalized()
     cmd.run()
     return cmd
 def _run(self, metadata=None, **options):
     if metadata is None:
         metadata = {'name': 'xxx', 'version': '1.2'}
     pkg_info, dist = self.create_dist(**metadata)
     cmd = check(dist)
     cmd.initialize_options()
     for name, value in options.items():
         setattr(cmd, name, value)
     cmd.ensure_finalized()
     cmd.run()
     return cmd
예제 #9
0
    def test_check_restructuredtext(self):
        # let's see if it detects broken rest in description
        broken_rest = 'title\n===\n\ntest'
        pkg_info, dist = self.create_dist(description=broken_rest)
        cmd = check(dist)
        cmd.check_restructuredtext()
        self.assertEqual(len(self.get_logs()), 1)

        # let's see if we have an error with strict=1
        metadata = {'home_page': 'xxx', 'author': 'xxx',
                    'author_email': 'xxx',
                    'name': 'xxx', 'version': '1.2',
                    'description': broken_rest}
        self.assertRaises(PackagingSetupError, self._run, metadata,
                          strict=True, all=True)
        self.loghandler.flush()

        # and non-broken rest, including a non-ASCII character to test #12114
        dist = self.create_dist(description=u'title\n=====\n\ntest \u00df')[1]
        cmd = check(dist)
        cmd.check_restructuredtext()
        self.assertEqual(self.get_logs(), [])
예제 #10
0
    def test_check_restructuredtext(self):
        if not _HAS_DOCUTILS: # won't test without docutils
            return
        # let's see if it detects broken rest in long_description
        broken_rest = 'title\n===\n\ntest'
        pkg_info, dist = self.create_dist(long_description=broken_rest)
        cmd = check(dist)
        cmd.check_restructuredtext()
        self.assertEquals(cmd._warnings, 1)

        # let's see if we have an error with strict=1
        metadata = {'url': 'xxx', 'author': 'xxx',
                    'author_email': 'xxx',
                    'name': 'xxx', 'version': 'xxx',
                    'long_description': broken_rest}
        self.assertRaises(DistutilsSetupError, self._run, metadata,
                          **{'strict': 1, 'restructuredtext': 1})

        # and non-broken rest
        metadata['long_description'] = 'title\n=====\n\ntest'
        cmd = self._run(metadata, strict=1, restructuredtext=1)
        self.assertEquals(cmd._warnings, 0)