Пример #1
0
    def test_markdown(self):
        # Markdown and text shouldn't get ReST errors
        testdata = COMPLETE.copy()
        testdata["long_description"] = "# Broken ReST\n\n``Valid  Markdown\n"
        testdata["long_description_content_type"] = "text/markdown"
        rating = rate(testdata)
        self.assertEqual(rating, (9, ["The package's long_description is quite short."]))

        testdata["long_description_content_type"] = "text/plain"
        rating = rate(testdata)
        self.assertEqual(rating, (9, ["The package's long_description is quite short."]))
Пример #2
0
def run(mode, argument):

    logging.info('-'*30)
    logging.info('Checking ' + argument)

    if mode == 'directory':
        data = projectdata.get_data(os.path.abspath(argument))
        logging.info('Found ' + data.get('name', 'nothing'))
    elif mode == 'file':
        data = distributiondata.get_data(os.path.abspath(argument))
        logging.info('Found ' + data.get('name', 'nothing'))
    else:
        # It's probably a package name
        data = pypidata.get_data(argument)
        logging.info('Found ' + data.get('name', 'nothing'))

    rating = ratings.rate(data)

    logging.info('-'*30)
    for problem in rating[1]:
        # XXX It would be nice with a * pointlist instead, but that requires
        # that we know how wide the terminal is and nice word-breaks, so that's
        # for later.
        logging.info(problem)
    if rating[1]:
        logging.info('-'*30)
    logging.info('Final rating: ' + str(rating[0]) + '/10')
    logging.info(ratings.LEVELS[rating[0]])
    logging.info('-'*30)

    return rating[0]
Пример #3
0
def run(mode, argument):

    logging.info('-'*30)
    logging.info('Checking ' + argument)

    if mode == 'directory':
        data = projectdata.get_data(os.path.abspath(argument))
        logging.info('Found ' + data.get('name', 'nothing'))
    elif mode == 'file':
        data = distributiondata.get_data(os.path.abspath(argument))
        logging.info('Found ' + data.get('name', 'nothing'))
    else:
        # It's probably a package name
        data = pypidata.get_data(argument)
        logging.info('Found ' + data.get('name', 'nothing'))

    rating = ratings.rate(data)

    logging.info('-'*30)
    for problem in rating[1]:
        # XXX It would be nice with a * pointlist instead, but that requires
        # that we know how wide the terminal is and nice word-breaks, so that's
        # for later.
        logging.info(problem)
    if rating[1]:
        logging.info('-'*30)
    logging.info('Final rating: ' + str(rating[0]) + '/10')
    logging.info(ratings.LEVELS[rating[0]])
    logging.info('-'*30)

    return rating[0]
Пример #4
0
    def test_distribute(self, projectdatamock):
        datafile = resource_filename(__name__, os.path.join("testdata", "jsondata", "distribute.json"))
        with open(datafile, "rt", encoding="UTF-8") as file:
            projectdatamock.return_value = json.load(file)

        proxystub.set_debug_context("distributedata.py", xmlrpclib.ServerProxy, False)

        data = pypidata.get_data("distribute")
        rating = rate(data)

        # build + older versions of setuptools works, later setuptools does not, so
        # we can get two different results here:
        self.assertEqual(
            rating,
            (
                7,
                [
                    "The classifiers should specify what minor versions of Python "
                    "you support as well as what major version.",
                    "You should have three or more owners of the project on PyPI.",
                    "Your Cheese may have spoiled!! The only way to gather metadata from your package was to execute "
                    "a patched setup.py. This indicates that your package is using very old packaging techniques, "
                    "(or that your setup.py isn't executable at all), and Pyroma will soon regard that as a "
                    "complete failure!\nPlease modernize your packaging! If it is already modern, this is a bug.",
                ],
            ),
        )
Пример #5
0
    def test_distribute(self):
        real_urlopen = urllib.urlopen
        real_server_proxy = xmlrpclib.ServerProxy
        try:
            xmlrpclib.ServerProxy = ProxyStub(
                "distributedata.py", xmlrpclib.ServerProxy, False
            )
            urllib.urlopen = urlopenstub
            data = pypidata.get_data("distribute")
            rating = rate(data)

            self.assertEqual(
                rating,
                (
                    9,
                    [
                        "The classifiers should specify what minor versions of Python "
                        "you support as well as what major version.",
                        "You should have three or more owners of the project on PyPI.",
                    ],
                ),
            )
        finally:
            xmlrpclib.ServerProxy = real_server_proxy
            urllib.urlopen = real_urlopen
Пример #6
0
def run(mode, argument):

    logging.info("-" * 30)
    logging.info("Checking " + argument)

    if mode == "directory":
        data = projectdata.get_data(os.path.abspath(argument))
        logging.info("Found " + data.get("name", "nothing"))
    elif mode == "file":
        data = distributiondata.get_data(os.path.abspath(argument))
        logging.info("Found " + data.get("name", "nothing"))
    else:
        # It's probably a package name
        data = pypidata.get_data(argument)
        logging.info("Found " + data.get("name", "nothing"))

    rating = ratings.rate(data)

    logging.info("-" * 30)
    for problem in rating[1]:
        # XXX It would be nice with a * pointlist instead, but that requires
        # that we know how wide the terminal is and nice word-breaks, so that's
        # for later.
        logging.info(problem)
    if rating[1]:
        logging.info("-" * 30)
    logging.info("Final rating: " + str(rating[0]) + "/10")
    logging.info(ratings.LEVELS[rating[0]])
    logging.info("-" * 30)

    return rating[0]
Пример #7
0
    def test_complete(self):
        directory = resource_filename(__name__,
                                      os.path.join('testdata', 'complete'))
        data = projectdata.get_data(directory)
        rating = rate(data)

        # Should have a perfect score
        self.assertEqual(rating, (10, []))
Пример #8
0
    def test_complete(self, projectdatamock):
        datafile = resource_filename(__name__, os.path.join("testdata", "jsondata", "complete.json"))
        with open(datafile, "rt", encoding="UTF-8") as file:
            projectdatamock.return_value = json.load(file)

        proxystub.set_debug_context("completedata.py", xmlrpclib.ServerProxy, False)

        data = pypidata.get_data("complete")
        rating = rate(data)

        self.assertEqual(rating, (10, []))
Пример #9
0
    def test_complete(self):
        real_urlopen = urllib.urlopen
        real_server_proxy = xmlrpclib.ServerProxy
        try:
            xmlrpclib.ServerProxy = ProxyStub('completedata.py',
                                              xmlrpclib.ServerProxy, False)
            urllib.urlopen = urlopenstub
            data = pypidata.get_data('complete')
            rating = rate(data)

            self.assertEqual(rating, (10, []))
        finally:
            xmlrpclib.ServerProxy = real_server_proxy
            urllib.urlopen = real_urlopen
Пример #10
0
    def test_distribute(self):
        real_urlopen = urllib.urlopen
        real_server_proxy = xmlrpclib.ServerProxy
        try:
            xmlrpclib.ServerProxy = ProxyStub('distributedata.py',
                                              xmlrpclib.ServerProxy, False)
            urllib.urlopen = urlopenstub
            data = pypidata.get_data('distribute')
            rating = rate(data)

            self.assertEqual(rating, (8, [
                'The classifiers should specify what minor versions of Python '
                'you support as well as what major version.',
                "The license specification 'PSF or ZPL' is not listed as a common name for 'License :: OSI Approved :: Zope Public License'. Expected 'ZPL'.",
                'You should have three or more owners of the project on PyPI.'
            ]))
        finally:
            xmlrpclib.ServerProxy = real_server_proxy
            urllib.urlopen = real_urlopen
Пример #11
0
    def test_distribute(self):
        real_urlopen = urllib.urlopen
        real_server_proxy = xmlrpclib.ServerProxy
        try:
            xmlrpclib.ServerProxy = ProxyStub('distributedata.py',
                                              xmlrpclib.ServerProxy, False)
            urllib.urlopen = urlopenstub
            data = pypidata.get_data('distribute')
            rating = rate(data)

            self.assertEqual(rating, (9, [
                'The classifiers should specify what minor versions of Python '
                'you support as well as what major version.',
                'You might want to host your documentation on readthedocs.org.',
                'You should have three or more owners of the project on PyPI.'
            ]))
        finally:
            xmlrpclib.ServerProxy = real_server_proxy
            urllib.urlopen = real_urlopen
Пример #12
0
    def test_lacking(self):
        directory = resource_filename(__name__,
                                      os.path.join('testdata', 'lacking'))
        data = projectdata.get_data(directory)
        rating = rate(data)

        self.assertEqual(rating, (0, [
            "The package had no description!",
            "The package's long_description is quite short.",
            "Your package does not have classifiers data.",
            "You should specify what Python versions you support.",
            "Your package does not have keywords data.",
            "Your package does not have author data.",
            "Your package does not have author_email data.",
            "Your package does not have url data.",
            "Your package does not have license data.",
            "You are using Setuptools or Distribute but do not specify if "
            "this package is zip_safe or not. You should specify it, as it "
            "defaults to True, which you probably do not want.",
        ]))
Пример #13
0
    def test_custom_test(self):
        directory = resource_filename(__name__,
                                      os.path.join('testdata', 'custom_test'))
        data = projectdata.get_data(directory)
        rating = rate(data)

        self.assertEqual(rating, (2, [
            "The package's version number does not comply with PEP-386 or PEP-440.",
            "The package's description should be longer than 10 characters.",
            "The package's long_description is quite short.",
            "Your package does not have classifiers data.",
            "You should specify what Python versions you support.",
            "Your package does not have keywords data.",
            "Your package does not have author data.",
            "Your package does not have author_email data.",
            "Your package should have a 'url' field with a link to the project home page, or a 'project_urls' field, with a dictionary of links, or both.",
            "Your package does neither have a license field nor any license classifiers.",
            "Specifying a development status in the classifiers gives users " \
            "a hint of how stable your software is.",
        ]))
Пример #14
0
    def test_lacking(self):
        directory = resource_filename(__name__,
                                      os.path.join('testdata', 'lacking'))
        data = projectdata.get_data(directory)
        rating = rate(data)

        self.assertEqual(rating, (0, [
            "The package had no description!",
            "The package's long_description is quite short.",
            "Your package does not have classifiers data.",
            "You should specify what Python versions you support.",
            "Your package does not have keywords data.",
            "Your package does not have author data.",
            "Your package does not have author_email data.",
            "Your package should have a 'url' field with a link to the project home page, or a 'project_urls' field, with a dictionary of links, or both.",
            "Your package does neither have a license field nor any license classifiers.",
            'Your long_description is not valid ReST: \n<string>:1: (WARNING/2) Inline literal start-string without end-string.',
            "Specifying a development status in the classifiers gives users " \
            "a hint of how stable your software is.",

        ]))
Пример #15
0
    def test_custom_test(self):
        directory = resource_filename(__name__,
                                      os.path.join('testdata', 'custom_test'))
        data = projectdata.get_data(directory)
        rating = rate(data)

        self.assertEqual(rating, (2, [
            "The package's version number does not comply with PEP-386 or PEP-440.",
            "The package's description should be longer than 10 characters.",
            "The package's long_description is quite short.",
            "Your package does not have classifiers data.",
            "You should specify what Python versions you support.",
            "Your package does not have keywords data.",
            "Your package does not have author data.",
            "Your package does not have author_email data.",
            "Your package does not have url data.",
            "Your package does not have license data.",
            "You are using Setuptools or Distribute but do not specify if "
            "this package is zip_safe or not. You should specify it, as it "
            "defaults to True, which you probably do not want.",
        ]))
Пример #16
0
    def test_distribute(self, projectdatamock):
        datafile = resource_filename(
            __name__, os.path.join("testdata", "jsondata", "distribute.json")
        )
        with open(datafile, "rt", encoding="UTF-8") as file:
            projectdatamock.return_value = json.load(file)

        proxystub.set_debug_context("distributedata.py", xmlrpclib.ServerProxy, False)

        data = pypidata.get_data("distribute")
        rating = rate(data)

        self.assertEqual(
            rating,
            (
                9,
                [
                    "The classifiers should specify what minor versions of Python "
                    "you support as well as what major version.",
                    "You should have three or more owners of the project on PyPI.",
                ],
            ),
        )
Пример #17
0
 def _get_file_rating(self, dirname):
     directory = resource_filename(__name__,
                                   os.path.join("testdata", dirname))
     data = projectdata.get_data(directory)
     return rate(data)