Skip to content
This repository was archived by the owner on Nov 27, 2022. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

Syntax Test Suite

This is a test suite project that is for scraping most common pypi packages and run syntax based analysis over them.

Usage

  • First go to test.py and fill a test_package_impl.
  • Then download pypi packages by python download.py [directory to download]
  • and finally run your test_package_impl by python test.py [directory where downloads are]

You can specify worker process/thread count by --workers

Example

Example implementation of test_packages_impl

deftest_package_impl(file: Path) ->List[Any]:
reports= []
try:
withtokenize.open(file) asf:
source=f.read()
source=ast.parse(source)
exceptSyntaxError:
returnreportsfornodeinast.walk(source):
ifisinstance(node, ast.Compare) andisinstance(node.left, ast.Constant):
forcomparatorinnode.comparators:
ifisinstance(comparator, (ast.Tuple, ast.List, ast.Set)) andall(isinstance(elt, ast.Constant) foreltincomparator.elts):
breakelse:
continuereports.append({"lineno": node.lineno, "source": ast.unparse(node)})
returnreports

And run

 $ python test.py packages --workers 8
==================================================
Package: pytest
Report(filename=PosixPath('packages/pytest-5.3.5/packages/pytest-5.3.5/doc/en/example/assertion/failure_demo.py'), report={'lineno': 81, 'source': '1 in [0, 2, 3, 4, 5]'})

About

Syntax Test Suite for Python

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages