How to use the prospector.autodetect.find_from_path function in prospector

To help you get started, we’ve selected a few prospector examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PyCQA / prospector / tests / test_autodetect.py View on Github external
def test_negative_misleading_bom(self):
        """ Negative test: file containing BOM that is not the correct encoding. """
        # given,
        bindata = codecs.BOM_UTF32_BE
        bindata += u'# latin1 character: ®'.encode('latin1')

        with self.make_pypath(bindata=bindata) as path:
            # exercise,
            with warnings.catch_warnings(record=True) as warned:
                find_from_path(path=path)
                # verify.
                self.assertGreaterEqual(len(warned), 1)
                self.assertIn(ImportWarning, [_w.category for _w in warned])
github PyCQA / prospector / tests / test_autodetect.py View on Github external
def test_latin1_coding_line2(self):
        """
        File containing latin1 at line 2 with 'coding' declaration at line 1.
        """
        # given,
        bindata = (u'# coding: latin1\n'
                   u'# latin1 character: ®\n'
                   u'import django\n'
                   ).encode('latin1')
        expected_names = ('django',)
        with self.make_pypath(bindata=bindata) as path:
            # exercise,
            names = find_from_path(path=path)
        # verify.
        self.assertEqual(set(expected_names), names)
github PyCQA / prospector / tests / test_autodetect.py View on Github external
def test_bom_encoded_filepath(self):
        """ File containing only a UTF32_BE byte order mark still decodes.  """
        # given,
        bindata = codecs.BOM_UTF32_BE
        bindata += (u'import django\n'
                    u'# UTF-32-BE character: ®\n'
                    ).encode('UTF-32BE')
        expected_names = ('django',)
        with self.make_pypath(bindata=bindata) as path:
            # exercise,
            names = find_from_path(path=path)
        # verify.
        self.assertEqual(set(expected_names), names)
github PyCQA / prospector / tests / test_autodetect.py View on Github external
def test_negative_latin1(self):
        """ Negative test: file containing latin1 without 'coding' declaration. """
        # given,
        bindata = u'# latin1 character: ®'.encode('latin1')

        with self.make_pypath(bindata=bindata) as path:
            # exercise,
            with warnings.catch_warnings(record=True) as warned:
                find_from_path(path=path)
                # verify.
                self.assertGreaterEqual(len(warned), 1)
                self.assertIn(ImportWarning, [_w.category for _w in warned])
github PyCQA / prospector / tests / test_autodetect.py View on Github external
def test_negative_lookuperror(self):
        """ File declares an unknown coding.  """
        # given,
        bindata = u'# coding: unknown\n'.encode('ascii')

        with self.make_pypath(bindata=bindata) as path:
            # exercise,
            with warnings.catch_warnings(record=True) as warned:
                find_from_path(path=path)
                # verify.
                self.assertGreaterEqual(len(warned), 1)
                self.assertIn(ImportWarning, [_w.category for _w in warned])