├── .flake8 ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── release.yml │ └── tests.yml ├── .gitignore ├── .travis.yml ├── CODE-OF-CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── art ├── logo.png ├── logo.svg └── logo2.svg ├── noxfile.py ├── poetry.lock ├── pyproject.toml ├── pytest_austin ├── __init__.py ├── markers.py └── plugin.py └── test ├── conftest.py └── test_pytest_austin.py /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | select = ANN,B,B9,C,D,E,F,W,I 3 | ignore = ANN101,B950,D100,D104,D107,D205,D212,D415,E203,E402,E501,F401,W503,W606 4 | max-line-length = 80 5 | docstring-convention = google 6 | import-order-style = google 7 | per-file-ignores = 8 | test/*:ANN,D 9 | noxfile.py:ANN,D 10 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: p403n1x87 2 | patreon: P403n1x87 3 | custom: "https://www.buymeacoffee.com/Q9C1Hnm28" 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | [Description of the issue] 4 | 5 | ### Steps to Reproduce 6 | 7 | 1. [First Step] 8 | 2. [Second Step] 9 | 3. [and so on...] 10 | 11 | **Expected behavior:** [What you expect to happen] 12 | 13 | **Actual behavior:** [What actually happens] 14 | 15 | **Reproduces how often:** [What percentage of the time does it reproduce?] 16 | 17 | ### Versions 18 | 19 | Please provide the version of pytest-austin that you are using. Also, please 20 | include the OS and what version of the OS you're running. 21 | 22 | ### Additional Information 23 | 24 | Any additional information, configuration or data that might be necessary to 25 | reproduce the issue. 26 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Requirements for Adding, Changing, Fixing or Removing a Feature 2 | 3 | Fill out the template below. Any pull request that does not include enough 4 | information to be reviewed in a timely manner may be closed at the maintainers' 5 | discretion. 6 | 7 | 8 | ### Description of the Change 9 | 10 | 16 | 17 | ### Alternate Designs 18 | 19 | 21 | 22 | ### Regressions 23 | 24 | 29 | 30 | ### Verification Process 31 | 32 | 42 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | release: 4 | types: [published] 5 | jobs: 6 | release: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - uses: actions/setup-python@v1 11 | with: 12 | python-version: '3.8' 13 | architecture: x64 14 | # - run: pip install nox==2020.5.24 15 | - run: pip install poetry==1.0.5 16 | # - run: nox 17 | - run: poetry build 18 | - run: poetry publish --username=__token__ --password=${{ secrets.PYPI_TOKEN }} 19 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: push 3 | jobs: 4 | tests: 5 | runs-on: ${{ matrix.os }} 6 | strategy: 7 | fail-fast: false 8 | matrix: 9 | os: [macos-latest, ubuntu-latest, windows-latest] 10 | name: Tests on ${{ matrix.os }} 11 | steps: 12 | - uses: actions/checkout@v2 13 | with: 14 | path: main 15 | 16 | - uses: actions/setup-python@v2 17 | with: 18 | python-version: '3.x' 19 | architecture: x64 20 | 21 | - name: Checkout Austin development branch 22 | uses: actions/checkout@master 23 | with: 24 | repository: P403n1x87/austin 25 | ref: devel 26 | path: austin 27 | 28 | - name: Compile Austin on Linux 29 | run: | 30 | cd $GITHUB_WORKSPACE/austin 31 | gcc -Wall -O3 -Os -s -pthread src/*.c -o src/austin 32 | sudo setcap cap_sys_ptrace+ep src/austin 33 | if: startsWith(matrix.os, 'ubuntu') 34 | 35 | - name: Compile Austin on Windows 36 | run: | 37 | cd $env:GITHUB_WORKSPACE/austin 38 | gcc.exe -O3 -o src/austin.exe src/*.c -lpsapi -Wall -Os -s 39 | if: startsWith(matrix.os, 'windows') 40 | 41 | - name: Compile Austin on macOS 42 | run: | 43 | cd $GITHUB_WORKSPACE/austin 44 | gcc -Wall -O3 -Os src/*.c -o src/austin 45 | if: startsWith(matrix.os, 'macos') 46 | 47 | - run: pip install nox==2020.5.24 48 | - run: pip install poetry==1.0.5 49 | 50 | - name: Run nox on Linux 51 | run: | 52 | cd $GITHUB_WORKSPACE/main 53 | export PATH="$GITHUB_WORKSPACE/austin/src:$PATH" 54 | nox 55 | if: "startsWith(matrix.os, 'ubuntu')" 56 | 57 | - name: Run nox on macOS 58 | run: | 59 | cd $GITHUB_WORKSPACE/main 60 | export PATH="$GITHUB_WORKSPACE/austin/src:$PATH" 61 | sudo nox 62 | if: startsWith(matrix.os, 'macos') 63 | 64 | - name: Run nox on Windows 65 | run: | 66 | cd $env:GITHUB_WORKSPACE/main 67 | $env:PATH="$env:GITHUB_WORKSPACE/austin/src;$env:PATH" 68 | $env:PYTHONIOENCODING="utf8" 69 | nox 70 | if: "startsWith(matrix.os, 'windows')" 71 | 72 | - name: Publish coverage metrics 73 | run: | 74 | cd $GITHUB_WORKSPACE/main 75 | nox -rs coverage 76 | if: startsWith(matrix.os, 'ubuntu') 77 | env: 78 | CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} 79 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | os: linux 3 | 4 | git: 5 | depth: 1 6 | 7 | osx_image: xcode10 8 | 9 | dist: bionic 10 | 11 | jobs: 12 | include: 13 | # Linux 14 | - env: TARGET=x86_64-unknown-linux-gnu 15 | os: linux 16 | 17 | before_script: 18 | # Install required Python versions 19 | - sudo add-apt-repository ppa:deadsnakes/ppa -y 20 | - sudo apt-get install python3.{6..9} python3.{6..9}-dev -y; 21 | 22 | # Clone Austin development branch 23 | - git clone --branch devel --depth 1 https://github.com/P403n1x87/austin.git ../austin 24 | 25 | # Compile Austin and grant CAP_SYS_PTRACE capability 26 | - cd ../austin 27 | - gcc -Wall -O3 -Os -s -pthread src/*.c -o src/austin 28 | - sudo setcap cap_sys_ptrace+ep src/austin 29 | - cd - 30 | 31 | - pip install nox==2020.5.24 32 | - pip install poetry==1.0.5 33 | 34 | script: 35 | - export PATH="`realpath ../austin/src`:$PATH" 36 | - nox 37 | - nox -rs coverage 38 | -------------------------------------------------------------------------------- /CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at [INSERT EMAIL ADDRESS]. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Austin 2 | 3 | Thanks for taking the time to contribute or considering doing so. 4 | 5 | The following is a set of guidelines for contributing to pytest-austin. 6 | 7 | ## Preamble 8 | 9 | TBD 10 | 11 | 12 | ## The Coding Style 13 | 14 | TBD 15 | 16 | 17 | ## Opening PRs 18 | 19 | Everybody is more than welcome to open a PR to fix a bug/propose enhancements/ 20 | implement missing features. If you do, please adhere to the following 21 | styleguides as much as possible. 22 | 23 | 24 | ### Git Commit Messages 25 | 26 | This styleguide is taken from the Atom project. 27 | 28 | * Use the present tense ("Add feature" not "Added feature") 29 | * Use the imperative mood ("Move cursor to..." not "Moves cursor to...") 30 | * Limit the first line to 72 characters or less 31 | * Reference issues and pull requests liberally after the first line 32 | 33 | 34 | ### Labels 35 | 36 | When opening a new PR, please apply a label to them. Try to use existing labels 37 | as much as possible and only create a new one if the current ones are not 38 | applicable. 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |
pytest-austin
3 |

4 | 5 |

Python Performance Testing with Austin

6 | 7 |

8 | 10 |      11 | 13 |      14 | 16 |

17 | 18 |

19 | 20 | GitHub Actions: Tests 22 | 23 | 24 | Travis CI 26 | 27 | 28 | Codecov 30 | 31 | 32 | PyPI 34 | 35 | 36 | LICENSE 38 | 39 |

40 | 41 |

42 | Synopsis • 43 | Installation • 44 | Usage • 45 | Compatibility • 46 | Contribute 47 |

48 | 49 |

50 | 53 | Buy Me A Coffee 56 | 57 |

58 | 59 | # Synopsis 60 | 61 | The pytest-austin plugin for [pytest](https://docs.pytest.org/en/stable/) brings 62 | Python performance testing right into your CI pipelines. It uses 63 | [Austin](https://github.com/P403n1x87/austin) to profile your test runs without 64 | any instrumentation. All you have to do is simply mark the tests on which you 65 | want to execute checks for preventing performance regressions. 66 | 67 | ~~~ Python 68 | import pytest 69 | 70 | 71 | @pytest.mark.total_time(td(milliseconds=50), function="fibonacci") 72 | @pytest.mark.total_time("99%", line=8) 73 | @pytest.mark.total_time("50.3141592653%", line=9) 74 | def test_hello_default(): 75 | fibonacci(27) 76 | fibonacci(25) 77 | ~~~ 78 | 79 | Any failed tests will be reported by pytest at the end of the session. All the 80 | collected statistics are written on a file prefixed with `austin_` and followed 81 | by a truncated timestamp, inside pytest rootdir. You can drop it onto 82 | [Speedscope](https://speedscope.app) for a quick visual representation of your 83 | tests. 84 | 85 | ~~~ 86 | ================================================================ test session starts ================================================================ 87 | platform linux -- Python 3.6.9, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 -- /home/gabriele/.cache/pypoetry/virtualenvs/pytest-austin-yu27Ep_e-py3.6/bin/python3.6 88 | cachedir: .pytest_cache 89 | rootdir: /tmp/pytest-of-gabriele/pytest-226/test_austin_time_checks0 90 | plugins: cov-2.10.0, austin-0.1.0 91 | collecting ... collected 3 items 92 | 93 | test_austin_time_checks.py::test_lines PASSED 94 | test_austin_time_checks.py::test_check_fails PASSED 95 | test_austin_time_checks.py::test_check_succeeds PASSED 96 | 97 | =================================================================== Austin report =================================================================== 98 | austin 2.0.0 99 | Collected stats written on /tmp/pytest-of-gabriele/pytest-226/test_austin_time_checks0/.austin_97148135487643.aprof 100 | 101 | 🕑 Sampling time (min/avg/max) : 376/3327/18019 μs 102 | 🐢 Long sampling rate : 87/87 (100.00 %) samples took longer than the sampling interval 103 | 💀 Error rate : 0/87 (0.00 %) invalid samples 104 | 105 | test_austin_time_checks.py::test_lines test_lines:19 (test_austin_time_checks.py) -16.0 ms (-78.2% of 20.5 ms) 106 | test_austin_time_checks.py::test_lines test_lines:18 (test_austin_time_checks.py) -4.1 ms (-10.1% of 40.3 ms) 107 | test_austin_time_checks.py::test_lines fibonacci (test_austin_time_checks.py) -9.3 ms (-18.6% of 50.0 ms) 108 | test_austin_time_checks.py::test_check_fails test_check_fails (test_austin_time_checks.py) +99.8 ms (9978.6% of 1000.0 μs) 109 | test_austin_time_checks.py::test_check_succeeds test_check_succeeds (test_austin_time_checks.py) -9.0 ms (-8.1% of 110.0 ms) 110 | 111 | ================================================================== 1 check failed =================================================================== 112 | 113 | ================================================================= 3 passed in 0.35s ================================================================= 114 | ~~~ 115 | 116 | 117 | # Installation 118 | 119 | pytest-austin can be installed directly from PyPI with 120 | 121 | ~~~ bash 122 | pip install pytest-austin --upgrade 123 | ~~~ 124 | 125 | **NOTE** In order for the plugin to work, the Austin binary needs to be on the 126 | ``PATH`` environment variable. See [Austin 127 | installation](https://github.com/P403n1x87/austin#installation) instructions to 128 | see how you can easily install Austin on your platform. 129 | 130 | For platform-specific issues and remarks, refer to the 131 | [Compatibility](#compatibility) section below. 132 | 133 | 134 | # Usage 135 | 136 | Once installed, the plugin will try to attach Austin to the pytest process in 137 | order to sample it every time you run pytest. If you want to prevent Austin from 138 | profiling your tests, you have to steal its mojo. You can do so with the 139 | `--steal-mojo` command line argument. 140 | 141 | 142 | ## Time checks 143 | 144 | The plugin looks for the `total_time` marker on collected test items, which 145 | takes a mandatory argument `time` and three optional ones: `function`, `module` 146 | and `line`. 147 | 148 | If you simply want to check that the duration of a test item doesn't take longer 149 | than `time`, you can mark it with `@pytest.mark.total_time(time)`. Here, `time` 150 | can either be a `float` (in seconds) or an instance of `datetime.timedelta`. 151 | 152 | ~~~ python 153 | from datetime import timedelta as td 154 | 155 | import pytest 156 | 157 | 158 | @pytest.mark.total_time(td(milliseconds=50)) 159 | def test_hello_default(): 160 | ... 161 | ~~~ 162 | 163 | In some cases, you would want to make sure that a function or method called on a 164 | certain line in your test script executes in under a certain amount of time, say 165 | 5% of the total test time. You can achieve this like so 166 | 167 | ~~~ python 168 | import pytest 169 | 170 | 171 | @pytest.mark.total_time("5%", line=7) 172 | def test_hello_default(): 173 | somefunction() 174 | fastfunction() # <- this is line no. 7 in the test script 175 | someotherfunction() 176 | ~~~ 177 | 178 | In many cases, however, one would want to test that a function or a method 179 | called either directly or indirectly by a test doesn't take more than a certain 180 | overall time to run. This is where the remaining arguments of the ``total_test`` 181 | marker come into play. Suppose that you want to profile the procedure ``bar`` 182 | that is called by method ``foo`` of an object of type ``Snafu``. To ensure that 183 | ``bar`` doesn't take longer than, say, 50% of the overall test duration, you can 184 | write 185 | 186 | ~~~ python 187 | import pytest 188 | 189 | 190 | @pytest.mark.total_time("50%", function="bar") 191 | def test_snafu(): 192 | ... 193 | snafu = Snafu() 194 | ... 195 | snafu.foo() 196 | ... 197 | ~~~ 198 | 199 | You can use the `module` argument to resolve function name clashes. For example, 200 | if the definition of the function/method `bar` occurs within the modules 201 | ``somemodule.py`` and ``someothermodule.py``, but you are only interested in the 202 | one defined in ``somemodule.py``, you can change the above into 203 | 204 | ~~~ python 205 | import pytest 206 | 207 | 208 | @pytest.mark.total_time("50%", function="bar", module="somemodule.py") 209 | def test_snafu(): 210 | ... 211 | snafu = Snafu() 212 | ... 213 | snafu.foo() 214 | ... 215 | ~~~ 216 | 217 | And whilst you can also specify a line number, this is perhaps not very handy 218 | and practical outside of test scripts themselves, unless the content of the 219 | module is stable enough that line numbers don't need to be updated very 220 | frequently. 221 | 222 | When the pluing runs, it will produce an output containing lines of the form 223 | 224 | ~~~ 225 | test_austin_time_checks.py::test_lines test_lines:19 (test_austin_time_checks.py) -16.0 ms (-78.2% of 20.5 ms) 226 | ~~~ 227 | 228 | In this case, a negative number, such as `-16.0 ms`, indicates that the total 229 | time spent on `test_lines:19 (test_austin_time_checks.py)` was 16.0 ms less 230 | than the total allowed time specified with the `total_time` marker, which in 231 | this example is 20.5 ms. Hence, negative numbers indicate a successful check. 232 | 233 | Failing tests will have a positive delta reported, e.g. 234 | 235 | ~~~ 236 | test_austin_time_checks.py::test_check_fails test_check_fails (test_austin_time_checks.py) +99.8 ms (9978.6% of 1000.0 μs) 237 | ~~~ 238 | 239 | This indicates that the total time spent on 240 | `test_check_fails (test_austin_time_checks.py)` was 99.8 ms more than the 241 | required threshold, which was set to 1 ms. 242 | 243 | ## Memory checks 244 | 245 | One can perform memory allocation checks with the `total_memory` marker. The 246 | first argument is ``size``, which can be a percentage of the total memory 247 | allocation of the marked test case, as well as an absolute measure of the 248 | maximum amount of memory, e.g., ``"24 MB"``. The ``function``, ``module`` and 249 | ``line`` are the same as for the ``total_time`` marker. The extra ``net`` 250 | argument can be set to ``True`` to check for the total _net_ memory usage, that 251 | is the difference between memory allocations and deallocations. 252 | 253 | ~~~ python 254 | import pytest 255 | 256 | 257 | @pytest.mark.total_memory("24 MB") 258 | def test_snafu(): 259 | allota_memory() 260 | ~~~ 261 | 262 | In order to perform memory checks, you need to specify either the ``memory`` or 263 | ``all`` profile mode via the ``--profile-mode`` option. 264 | 265 | The negative and positive memory deltas reported by the plugin in the report 266 | behave like the time deltas described in the previous section. That is, a 267 | negative memory delta indicates a successful check, whereas a positive delta 268 | indicates a check that has failed. 269 | 270 | ## Mixed checks 271 | 272 | When in the ``all`` profile mode, you can perform both time and memory checks by 273 | stacking ``total_time`` and ``total_memory`` markers. 274 | 275 | ~~~ python 276 | import pytest 277 | 278 | 279 | @pytest.mark.total_time(5.15) 280 | @pytest.mark.total_memory("24 MB") 281 | def test_snafu(): 282 | allota_memory_and_time() 283 | ~~~ 284 | 285 | 286 | ## Multi-processing 287 | 288 | If your tests spawn other Python processes, you can ask pytest-austin to profile 289 | them too with the ``--minime`` option. Note that if your tests are spawning too 290 | many non-Python processes, the sampling rate might be affected because of the 291 | way that Austin tries to discover Python child processes. 292 | 293 | ## Reporting 294 | 295 | This plugins generate a report on terminal and dumps the collected profiling 296 | statistics on the file system as well, for later analysis and visualisation. The 297 | verbosity of the terminal report can be controlled with the ``--austin-report`` 298 | option. By default, it is set to ``minimal``, which means that only checks that 299 | have failed will be reported. Use ``full`` to see the results for all the checks 300 | that have been detected and executed by the plugin. 301 | 302 | Regarding the dump of the profiling statistics, the generated file is in the 303 | Austin format by default (this is a generalisation of the collapsed stack 304 | format). If you want the plugin to dump the data in either the ``pprof`` or 305 | ``speedscope`` format, you can set the ``--profile-format`` option accordingly. 306 | 307 | 308 | # Compatibility 309 | 310 | This plugin has been tested on Linux, MacOS and Windows. Given that it relies on 311 | [Austin](https://github.com/P403n1x87/austin) for sampling the frame stacks of 312 | the pytest process, its compatibility considerations apply to pytest-austin as 313 | well. 314 | 315 | On Linux, the use of ``sudo`` is required, unless the ``CAP_SYS_PTRACE`` 316 | capability is granted to the Austin binary with, e.g. 317 | 318 | ~~~ bash 319 | sudo setcap cap_sys_ptrace+ep `which austin` 320 | ~~~ 321 | 322 | Then the use of ``sudo`` is no longer required to allow Austin to attach and 323 | sample pytest. 324 | 325 | On MacOS, the use of ``sudo`` is also mandatory, unless the user that is 326 | invoking pytest belongs to the ``procmod`` group. 327 | 328 | 329 | # Contribute 330 | 331 | If you like pytest-austin and you find it useful, there are ways for you to 332 | contribute. 333 | 334 | If you want to help with the development, then have a look at the open issues 335 | and have a look at the [contributing guidelines](CONTRIBUTING.md) before you 336 | open a pull request. 337 | 338 | You can also contribute to the development of the pytest-austin by becoming a 339 | sponsor and/or by [buying me a coffee](https://www.buymeacoffee.com/Q9C1Hnm28) 340 | on BMC or by chipping in a few pennies on 341 | [PayPal.Me](https://www.paypal.me/gtornetta/1). 342 | 343 |

344 | 346 | Buy Me A Coffee 348 | 349 |

350 | -------------------------------------------------------------------------------- /art/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/P403n1x87/pytest-austin/3c8abcfa3e7c3b9520a82effb4df86fc1a44b137/art/logo.png -------------------------------------------------------------------------------- /art/logo2.svg: -------------------------------------------------------------------------------- 1 | 2 | 21 | 23 | 26 | 30 | 34 | 35 | 41 | 51 | 61 | 64 | 68 | 72 | 76 | 77 | 86 | 94 | 98 | 99 | 102 | 106 | 109 | 115 | 121 | 122 | 123 | 131 | 136 | 140 | 141 | 147 | 153 | 159 | 165 | 171 | 177 | 183 | 192 | 201 | 210 | 211 | 235 | 237 | 238 | 240 | image/svg+xml 241 | 243 | 244 | 245 | 246 | 247 | 252 | 255 | 261 | 273 | 285 | 286 | 290 | 296 | 308 | 320 | 321 | 322 | 332 | 338 | 341 | 347 | 353 | 354 | 357 | 363 | 369 | 370 | 371 | 376 | pytest 386 | austin 396 | 397 | 398 | -------------------------------------------------------------------------------- /noxfile.py: -------------------------------------------------------------------------------- 1 | import os 2 | import tempfile 3 | 4 | import nox 5 | 6 | 7 | nox.options.sessions = ["lint", "tests"] 8 | 9 | 10 | # ---- Configuration ---- 11 | 12 | 13 | SUPPORTED_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] 14 | 15 | PYTEST_OPTIONS = [ 16 | "-vvvs", 17 | "--cov=pytest_austin", 18 | "--cov-report", 19 | "term-missing", 20 | "--steal-mojo", 21 | ] 22 | 23 | LINT_LOCATIONS = ["pytest_austin", "test", "noxfile.py"] 24 | LINT_EXCLUDES = [] 25 | 26 | MYPY_LOCATIONS = LINT_LOCATIONS[:1] 27 | 28 | 29 | # ---- Helpers ---- 30 | 31 | 32 | def install_with_constraints(session, *args, **kwargs): 33 | with tempfile.NamedTemporaryFile() as requirements: 34 | session.run( 35 | "poetry", 36 | "export", 37 | "--dev", 38 | "--format=requirements.txt", 39 | f"--output={requirements.name}", 40 | external=True, 41 | ) 42 | session.install(f"--constraint={requirements.name}", *args, **kwargs) 43 | 44 | 45 | # ---- Sessions ---- 46 | 47 | 48 | @nox.session(python=SUPPORTED_PYTHON_VERSIONS) 49 | def tests(session): 50 | session.run("poetry", "install", "-vv", external=True) 51 | session.run( 52 | "poetry", "run", "python", "-m", "pytest", *PYTEST_OPTIONS, 53 | ) 54 | 55 | 56 | @nox.session(python=SUPPORTED_PYTHON_VERSIONS) 57 | def lint(session): 58 | session.install( 59 | "flake8", "flake8-bugbear", "flake8-docstrings", "flake8-import-order", 60 | ) 61 | session.run("flake8", *LINT_LOCATIONS) # , "--exclude", *LINT_EXCLUDES) 62 | 63 | 64 | @nox.session(python="3.7") 65 | def coverage(session): 66 | """Upload coverage data.""" 67 | install_with_constraints(session, "coverage[toml]", "codecov") 68 | session.run("coverage", "xml", "--fail-under=0") 69 | session.run("codecov", *session.posargs) 70 | -------------------------------------------------------------------------------- /poetry.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | category = "main" 3 | description = "Produce colored terminal text with an xml-like markup" 4 | name = "ansimarkup" 5 | optional = false 6 | python-versions = "*" 7 | version = "1.4.0" 8 | 9 | [package.dependencies] 10 | colorama = "*" 11 | 12 | [package.extras] 13 | devel = ["bumpversion (>=0.5.2)", "check-manifest (>=0.35)", "readme-renderer (>=16.0)", "flake8", "pep8-naming"] 14 | tests = ["tox (>=2.6.0)", "pytest (>=3.0.3)", "pytest-cov (>=2.3.1)"] 15 | 16 | [[package]] 17 | category = "dev" 18 | description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." 19 | name = "appdirs" 20 | optional = false 21 | python-versions = "*" 22 | version = "1.4.4" 23 | 24 | [[package]] 25 | category = "dev" 26 | description = "Bash tab completion for argparse" 27 | name = "argcomplete" 28 | optional = false 29 | python-versions = "*" 30 | version = "1.12.1" 31 | 32 | [package.dependencies] 33 | [package.dependencies.importlib-metadata] 34 | python = ">=3.6,<3.7" 35 | version = ">=0.23,<3" 36 | 37 | [package.extras] 38 | test = ["coverage", "flake8", "pexpect", "wheel"] 39 | 40 | [[package]] 41 | category = "dev" 42 | description = "Atomic file writes." 43 | marker = "sys_platform == \"win32\"" 44 | name = "atomicwrites" 45 | optional = false 46 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 47 | version = "1.4.0" 48 | 49 | [[package]] 50 | category = "dev" 51 | description = "Classes Without Boilerplate" 52 | name = "attrs" 53 | optional = false 54 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 55 | version = "20.2.0" 56 | 57 | [package.extras] 58 | dev = ["coverage (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface", "sphinx", "sphinx-rtd-theme", "pre-commit"] 59 | docs = ["sphinx", "sphinx-rtd-theme", "zope.interface"] 60 | tests = ["coverage (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface"] 61 | tests_no_zope = ["coverage (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six"] 62 | 63 | [[package]] 64 | category = "main" 65 | description = "Python wrapper for Austin, the frame stack sampler for CPython" 66 | name = "austin-python" 67 | optional = false 68 | python-versions = ">=3.6,<4.0" 69 | version = "0.1.0" 70 | 71 | [package.dependencies] 72 | dataclasses = "*" 73 | protobuf = ">=3.12.2,<4.0.0" 74 | psutil = ">=5.7.0" 75 | 76 | [[package]] 77 | category = "dev" 78 | description = "Python package for providing Mozilla's CA Bundle." 79 | name = "certifi" 80 | optional = false 81 | python-versions = "*" 82 | version = "2020.6.20" 83 | 84 | [[package]] 85 | category = "dev" 86 | description = "Universal encoding detector for Python 2 and 3" 87 | name = "chardet" 88 | optional = false 89 | python-versions = "*" 90 | version = "3.0.4" 91 | 92 | [[package]] 93 | category = "dev" 94 | description = "Hosted coverage reports for GitHub, Bitbucket and Gitlab" 95 | name = "codecov" 96 | optional = false 97 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 98 | version = "2.1.10" 99 | 100 | [package.dependencies] 101 | coverage = "*" 102 | requests = ">=2.7.9" 103 | 104 | [[package]] 105 | category = "main" 106 | description = "Cross-platform colored terminal text." 107 | name = "colorama" 108 | optional = false 109 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" 110 | version = "0.4.3" 111 | 112 | [[package]] 113 | category = "dev" 114 | description = "Log formatting with colors!" 115 | name = "colorlog" 116 | optional = false 117 | python-versions = "*" 118 | version = "4.4.0" 119 | 120 | [package.dependencies] 121 | colorama = "*" 122 | 123 | [[package]] 124 | category = "dev" 125 | description = "Code coverage measurement for Python" 126 | name = "coverage" 127 | optional = false 128 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" 129 | version = "5.2.1" 130 | 131 | [package.dependencies] 132 | [package.dependencies.toml] 133 | optional = true 134 | version = "*" 135 | 136 | [package.extras] 137 | toml = ["toml"] 138 | 139 | [[package]] 140 | category = "main" 141 | description = "A backport of the dataclasses module for Python 3.6" 142 | name = "dataclasses" 143 | optional = false 144 | python-versions = "*" 145 | version = "0.6" 146 | 147 | [[package]] 148 | category = "dev" 149 | description = "Distribution utilities" 150 | name = "distlib" 151 | optional = false 152 | python-versions = "*" 153 | version = "0.3.1" 154 | 155 | [[package]] 156 | category = "dev" 157 | description = "A platform independent file lock." 158 | name = "filelock" 159 | optional = false 160 | python-versions = "*" 161 | version = "3.0.12" 162 | 163 | [[package]] 164 | category = "dev" 165 | description = "Internationalized Domain Names in Applications (IDNA)" 166 | name = "idna" 167 | optional = false 168 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 169 | version = "2.10" 170 | 171 | [[package]] 172 | category = "dev" 173 | description = "Read metadata from Python packages" 174 | marker = "python_version < \"3.8\"" 175 | name = "importlib-metadata" 176 | optional = false 177 | python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" 178 | version = "2.0.0" 179 | 180 | [package.dependencies] 181 | zipp = ">=0.5" 182 | 183 | [package.extras] 184 | docs = ["sphinx", "rst.linker"] 185 | testing = ["packaging", "pep517", "importlib-resources (>=1.3)"] 186 | 187 | [[package]] 188 | category = "dev" 189 | description = "Read resources from Python packages" 190 | marker = "python_version < \"3.7\"" 191 | name = "importlib-resources" 192 | optional = false 193 | python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" 194 | version = "3.0.0" 195 | 196 | [package.dependencies] 197 | [package.dependencies.zipp] 198 | python = "<3.8" 199 | version = ">=0.4" 200 | 201 | [package.extras] 202 | docs = ["sphinx", "rst.linker", "jaraco.packaging"] 203 | 204 | [[package]] 205 | category = "dev" 206 | description = "iniconfig: brain-dead simple config-ini parsing" 207 | name = "iniconfig" 208 | optional = false 209 | python-versions = "*" 210 | version = "1.0.1" 211 | 212 | [[package]] 213 | category = "dev" 214 | description = "Flexible test automation." 215 | name = "nox" 216 | optional = false 217 | python-versions = ">=3.5" 218 | version = "2020.8.22" 219 | 220 | [package.dependencies] 221 | argcomplete = ">=1.9.4,<2.0" 222 | colorlog = ">=2.6.1,<5.0.0" 223 | py = ">=1.4.0,<2.0.0" 224 | virtualenv = ">=14.0.0" 225 | 226 | [package.dependencies.importlib-metadata] 227 | python = "<3.8" 228 | version = "*" 229 | 230 | [package.extras] 231 | tox_to_nox = ["jinja2", "tox"] 232 | 233 | [[package]] 234 | category = "dev" 235 | description = "Core utilities for Python packages" 236 | name = "packaging" 237 | optional = false 238 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 239 | version = "20.4" 240 | 241 | [package.dependencies] 242 | pyparsing = ">=2.0.2" 243 | six = "*" 244 | 245 | [[package]] 246 | category = "dev" 247 | description = "plugin and hook calling mechanisms for python" 248 | name = "pluggy" 249 | optional = false 250 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 251 | version = "0.13.1" 252 | 253 | [package.dependencies] 254 | [package.dependencies.importlib-metadata] 255 | python = "<3.8" 256 | version = ">=0.12" 257 | 258 | [package.extras] 259 | dev = ["pre-commit", "tox"] 260 | 261 | [[package]] 262 | category = "main" 263 | description = "Protocol Buffers" 264 | name = "protobuf" 265 | optional = false 266 | python-versions = "*" 267 | version = "3.13.0" 268 | 269 | [package.dependencies] 270 | setuptools = "*" 271 | six = ">=1.9" 272 | 273 | [[package]] 274 | category = "main" 275 | description = "Cross-platform lib for process and system monitoring in Python." 276 | name = "psutil" 277 | optional = false 278 | python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 279 | version = "5.7.2" 280 | 281 | [package.extras] 282 | test = ["ipaddress", "mock", "unittest2", "enum34", "pywin32", "wmi"] 283 | 284 | [[package]] 285 | category = "dev" 286 | description = "library with cross-python path, ini-parsing, io, code, log facilities" 287 | name = "py" 288 | optional = false 289 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 290 | version = "1.9.0" 291 | 292 | [[package]] 293 | category = "dev" 294 | description = "Python parsing module" 295 | name = "pyparsing" 296 | optional = false 297 | python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" 298 | version = "2.4.7" 299 | 300 | [[package]] 301 | category = "dev" 302 | description = "pytest: simple powerful testing with Python" 303 | name = "pytest" 304 | optional = false 305 | python-versions = ">=3.5" 306 | version = "6.1.1" 307 | 308 | [package.dependencies] 309 | atomicwrites = ">=1.0" 310 | attrs = ">=17.4.0" 311 | colorama = "*" 312 | iniconfig = "*" 313 | packaging = "*" 314 | pluggy = ">=0.12,<1.0" 315 | py = ">=1.8.2" 316 | toml = "*" 317 | 318 | [package.dependencies.importlib-metadata] 319 | python = "<3.8" 320 | version = ">=0.12" 321 | 322 | [package.extras] 323 | checkqa_mypy = ["mypy (0.780)"] 324 | testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] 325 | 326 | [[package]] 327 | category = "dev" 328 | description = "Pytest plugin for measuring coverage." 329 | name = "pytest-cov" 330 | optional = false 331 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" 332 | version = "2.10.1" 333 | 334 | [package.dependencies] 335 | coverage = ">=4.4" 336 | pytest = ">=4.6" 337 | 338 | [package.extras] 339 | testing = ["fields", "hunter", "process-tests (2.0.2)", "six", "pytest-xdist", "virtualenv"] 340 | 341 | [[package]] 342 | category = "dev" 343 | description = "Python HTTP for Humans." 344 | name = "requests" 345 | optional = false 346 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" 347 | version = "2.24.0" 348 | 349 | [package.dependencies] 350 | certifi = ">=2017.4.17" 351 | chardet = ">=3.0.2,<4" 352 | idna = ">=2.5,<3" 353 | urllib3 = ">=1.21.1,<1.25.0 || >1.25.0,<1.25.1 || >1.25.1,<1.26" 354 | 355 | [package.extras] 356 | security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)"] 357 | socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7)", "win-inet-pton"] 358 | 359 | [[package]] 360 | category = "main" 361 | description = "Python 2 and 3 compatibility utilities" 362 | name = "six" 363 | optional = false 364 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" 365 | version = "1.15.0" 366 | 367 | [[package]] 368 | category = "dev" 369 | description = "Python Library for Tom's Obvious, Minimal Language" 370 | name = "toml" 371 | optional = false 372 | python-versions = "*" 373 | version = "0.10.1" 374 | 375 | [[package]] 376 | category = "dev" 377 | description = "HTTP library with thread-safe connection pooling, file post, and more." 378 | name = "urllib3" 379 | optional = false 380 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" 381 | version = "1.25.10" 382 | 383 | [package.extras] 384 | brotli = ["brotlipy (>=0.6.0)"] 385 | secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "pyOpenSSL (>=0.14)", "ipaddress"] 386 | socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"] 387 | 388 | [[package]] 389 | category = "dev" 390 | description = "Virtual Python Environment builder" 391 | name = "virtualenv" 392 | optional = false 393 | python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" 394 | version = "20.0.33" 395 | 396 | [package.dependencies] 397 | appdirs = ">=1.4.3,<2" 398 | distlib = ">=0.3.1,<1" 399 | filelock = ">=3.0.0,<4" 400 | six = ">=1.9.0,<2" 401 | 402 | [package.dependencies.importlib-metadata] 403 | python = "<3.8" 404 | version = ">=0.12,<3" 405 | 406 | [package.dependencies.importlib-resources] 407 | python = "<3.7" 408 | version = ">=1.0" 409 | 410 | [package.extras] 411 | docs = ["proselint (>=0.10.2)", "sphinx (>=3)", "sphinx-argparse (>=0.2.5)", "sphinx-rtd-theme (>=0.4.3)", "towncrier (>=19.9.0rc1)"] 412 | testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)", "pytest (>=4)", "pytest-env (>=0.6.2)", "pytest-freezegun (>=0.4.1)", "pytest-mock (>=2)", "pytest-randomly (>=1)", "pytest-timeout (>=1)", "pytest-xdist (>=1.31.0)", "packaging (>=20.0)", "xonsh (>=0.9.16)"] 413 | 414 | [[package]] 415 | category = "dev" 416 | description = "Backport of pathlib-compatible object wrapper for zip files" 417 | marker = "python_version < \"3.8\"" 418 | name = "zipp" 419 | optional = false 420 | python-versions = ">=3.6" 421 | version = "3.3.0" 422 | 423 | [package.extras] 424 | docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] 425 | testing = ["pytest (>=3.5,<3.7.3 || >3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pytest-cov", "jaraco.test (>=3.2.0)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"] 426 | 427 | [metadata] 428 | content-hash = "14a5cf77a1b777f130076b95d4bfe0fcbd074a56be83935b5a4e4c03648d7c51" 429 | python-versions = "^3.6" 430 | 431 | [metadata.files] 432 | ansimarkup = [ 433 | {file = "ansimarkup-1.4.0-py2.py3-none-any.whl", hash = "sha256:06365e3ef89a12734fc408b2449cb4642d5fe2e603e95e7296eff9e98a0fe0b4"}, 434 | {file = "ansimarkup-1.4.0.tar.gz", hash = "sha256:174d920481416cec8d5a707af542d6fba25a1df1c21d8996479c32ba453649a4"}, 435 | ] 436 | appdirs = [ 437 | {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, 438 | {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, 439 | ] 440 | argcomplete = [ 441 | {file = "argcomplete-1.12.1-py2.py3-none-any.whl", hash = "sha256:5cd1ac4fc49c29d6016fc2cc4b19a3c08c3624544503495bf25989834c443898"}, 442 | {file = "argcomplete-1.12.1.tar.gz", hash = "sha256:849c2444c35bb2175aea74100ca5f644c29bf716429399c0f2203bb5d9a8e4e6"}, 443 | ] 444 | atomicwrites = [ 445 | {file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, 446 | {file = "atomicwrites-1.4.0.tar.gz", hash = "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"}, 447 | ] 448 | attrs = [ 449 | {file = "attrs-20.2.0-py2.py3-none-any.whl", hash = "sha256:fce7fc47dfc976152e82d53ff92fa0407700c21acd20886a13777a0d20e655dc"}, 450 | {file = "attrs-20.2.0.tar.gz", hash = "sha256:26b54ddbbb9ee1d34d5d3668dd37d6cf74990ab23c828c2888dccdceee395594"}, 451 | ] 452 | austin-python = [ 453 | {file = "austin-python-0.1.0.tar.gz", hash = "sha256:7a744eb98b0b9f23d92911ff918c5aa8a5509e7f9ccfa7c608f0a3dc180ae323"}, 454 | {file = "austin_python-0.1.0-py3-none-any.whl", hash = "sha256:234562e5a76c86de657fe04a1d049f1b265228d8ab7f6ba26724c835c9007b10"}, 455 | ] 456 | certifi = [ 457 | {file = "certifi-2020.6.20-py2.py3-none-any.whl", hash = "sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41"}, 458 | {file = "certifi-2020.6.20.tar.gz", hash = "sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3"}, 459 | ] 460 | chardet = [ 461 | {file = "chardet-3.0.4-py2.py3-none-any.whl", hash = "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"}, 462 | {file = "chardet-3.0.4.tar.gz", hash = "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"}, 463 | ] 464 | codecov = [ 465 | {file = "codecov-2.1.10-py2.py3-none-any.whl", hash = "sha256:61bc71b5f58be8000bf9235aa9d0112f8fd3acca00aa02191bb81426d22a8584"}, 466 | {file = "codecov-2.1.10-py3.8.egg", hash = "sha256:a333626e6ff882db760ce71a1d84baf80ddff2cd459a3cc49b41fdac47d77ca5"}, 467 | {file = "codecov-2.1.10.tar.gz", hash = "sha256:d30ad6084501224b1ba699cbf018a340bb9553eb2701301c14133995fdd84f33"}, 468 | ] 469 | colorama = [ 470 | {file = "colorama-0.4.3-py2.py3-none-any.whl", hash = "sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff"}, 471 | {file = "colorama-0.4.3.tar.gz", hash = "sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"}, 472 | ] 473 | colorlog = [ 474 | {file = "colorlog-4.4.0-py2.py3-none-any.whl", hash = "sha256:f14f30f58e2ce6ef40b0088307cac7efb9ecff5605fa2267a2d29955f26aff23"}, 475 | {file = "colorlog-4.4.0.tar.gz", hash = "sha256:0272c537469ab1e63b9915535874d15b671963c9325db0c4891a2aeff97ce3d1"}, 476 | ] 477 | coverage = [ 478 | {file = "coverage-5.2.1-cp27-cp27m-macosx_10_13_intel.whl", hash = "sha256:40f70f81be4d34f8d491e55936904db5c527b0711b2a46513641a5729783c2e4"}, 479 | {file = "coverage-5.2.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:675192fca634f0df69af3493a48224f211f8db4e84452b08d5fcebb9167adb01"}, 480 | {file = "coverage-5.2.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:2fcc8b58953d74d199a1a4d633df8146f0ac36c4e720b4a1997e9b6327af43a8"}, 481 | {file = "coverage-5.2.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:64c4f340338c68c463f1b56e3f2f0423f7b17ba6c3febae80b81f0e093077f59"}, 482 | {file = "coverage-5.2.1-cp27-cp27m-win32.whl", hash = "sha256:52f185ffd3291196dc1aae506b42e178a592b0b60a8610b108e6ad892cfc1bb3"}, 483 | {file = "coverage-5.2.1-cp27-cp27m-win_amd64.whl", hash = "sha256:30bc103587e0d3df9e52cd9da1dd915265a22fad0b72afe54daf840c984b564f"}, 484 | {file = "coverage-5.2.1-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:9ea749fd447ce7fb1ac71f7616371f04054d969d412d37611716721931e36efd"}, 485 | {file = "coverage-5.2.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:ce7866f29d3025b5b34c2e944e66ebef0d92e4a4f2463f7266daa03a1332a651"}, 486 | {file = "coverage-5.2.1-cp35-cp35m-macosx_10_13_x86_64.whl", hash = "sha256:4869ab1c1ed33953bb2433ce7b894a28d724b7aa76c19b11e2878034a4e4680b"}, 487 | {file = "coverage-5.2.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:a3ee9c793ffefe2944d3a2bd928a0e436cd0ac2d9e3723152d6fd5398838ce7d"}, 488 | {file = "coverage-5.2.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:28f42dc5172ebdc32622a2c3f7ead1b836cdbf253569ae5673f499e35db0bac3"}, 489 | {file = "coverage-5.2.1-cp35-cp35m-win32.whl", hash = "sha256:e26c993bd4b220429d4ec8c1468eca445a4064a61c74ca08da7429af9bc53bb0"}, 490 | {file = "coverage-5.2.1-cp35-cp35m-win_amd64.whl", hash = "sha256:4186fc95c9febeab5681bc3248553d5ec8c2999b8424d4fc3a39c9cba5796962"}, 491 | {file = "coverage-5.2.1-cp36-cp36m-macosx_10_13_x86_64.whl", hash = "sha256:b360d8fd88d2bad01cb953d81fd2edd4be539df7bfec41e8753fe9f4456a5082"}, 492 | {file = "coverage-5.2.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:1adb6be0dcef0cf9434619d3b892772fdb48e793300f9d762e480e043bd8e716"}, 493 | {file = "coverage-5.2.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:098a703d913be6fbd146a8c50cc76513d726b022d170e5e98dc56d958fd592fb"}, 494 | {file = "coverage-5.2.1-cp36-cp36m-win32.whl", hash = "sha256:962c44070c281d86398aeb8f64e1bf37816a4dfc6f4c0f114756b14fc575621d"}, 495 | {file = "coverage-5.2.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b1ed2bdb27b4c9fc87058a1cb751c4df8752002143ed393899edb82b131e0546"}, 496 | {file = "coverage-5.2.1-cp37-cp37m-macosx_10_13_x86_64.whl", hash = "sha256:c890728a93fffd0407d7d37c1e6083ff3f9f211c83b4316fae3778417eab9811"}, 497 | {file = "coverage-5.2.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:538f2fd5eb64366f37c97fdb3077d665fa946d2b6d95447622292f38407f9258"}, 498 | {file = "coverage-5.2.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:27ca5a2bc04d68f0776f2cdcb8bbd508bbe430a7bf9c02315cd05fb1d86d0034"}, 499 | {file = "coverage-5.2.1-cp37-cp37m-win32.whl", hash = "sha256:aab75d99f3f2874733946a7648ce87a50019eb90baef931698f96b76b6769a46"}, 500 | {file = "coverage-5.2.1-cp37-cp37m-win_amd64.whl", hash = "sha256:c2ff24df02a125b7b346c4c9078c8936da06964cc2d276292c357d64378158f8"}, 501 | {file = "coverage-5.2.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:304fbe451698373dc6653772c72c5d5e883a4aadaf20343592a7abb2e643dae0"}, 502 | {file = "coverage-5.2.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:c96472b8ca5dc135fb0aa62f79b033f02aa434fb03a8b190600a5ae4102df1fd"}, 503 | {file = "coverage-5.2.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:8505e614c983834239f865da2dd336dcf9d72776b951d5dfa5ac36b987726e1b"}, 504 | {file = "coverage-5.2.1-cp38-cp38-win32.whl", hash = "sha256:700997b77cfab016533b3e7dbc03b71d33ee4df1d79f2463a318ca0263fc29dd"}, 505 | {file = "coverage-5.2.1-cp38-cp38-win_amd64.whl", hash = "sha256:46794c815e56f1431c66d81943fa90721bb858375fb36e5903697d5eef88627d"}, 506 | {file = "coverage-5.2.1-cp39-cp39-macosx_10_13_x86_64.whl", hash = "sha256:16042dc7f8e632e0dcd5206a5095ebd18cb1d005f4c89694f7f8aafd96dd43a3"}, 507 | {file = "coverage-5.2.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:c1bbb628ed5192124889b51204de27c575b3ffc05a5a91307e7640eff1d48da4"}, 508 | {file = "coverage-5.2.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:4f6428b55d2916a69f8d6453e48a505c07b2245653b0aa9f0dee38785939f5e4"}, 509 | {file = "coverage-5.2.1-cp39-cp39-win32.whl", hash = "sha256:9e536783a5acee79a9b308be97d3952b662748c4037b6a24cbb339dc7ed8eb89"}, 510 | {file = "coverage-5.2.1-cp39-cp39-win_amd64.whl", hash = "sha256:b8f58c7db64d8f27078cbf2a4391af6aa4e4767cc08b37555c4ae064b8558d9b"}, 511 | {file = "coverage-5.2.1.tar.gz", hash = "sha256:a34cb28e0747ea15e82d13e14de606747e9e484fb28d63c999483f5d5188e89b"}, 512 | ] 513 | dataclasses = [ 514 | {file = "dataclasses-0.6-py3-none-any.whl", hash = "sha256:454a69d788c7fda44efd71e259be79577822f5e3f53f029a22d08004e951dc9f"}, 515 | {file = "dataclasses-0.6.tar.gz", hash = "sha256:6988bd2b895eef432d562370bb707d540f32f7360ab13da45340101bc2307d84"}, 516 | ] 517 | distlib = [ 518 | {file = "distlib-0.3.1-py2.py3-none-any.whl", hash = "sha256:8c09de2c67b3e7deef7184574fc060ab8a793e7adbb183d942c389c8b13c52fb"}, 519 | {file = "distlib-0.3.1.zip", hash = "sha256:edf6116872c863e1aa9d5bb7cb5e05a022c519a4594dc703843343a9ddd9bff1"}, 520 | ] 521 | filelock = [ 522 | {file = "filelock-3.0.12-py3-none-any.whl", hash = "sha256:929b7d63ec5b7d6b71b0fa5ac14e030b3f70b75747cef1b10da9b879fef15836"}, 523 | {file = "filelock-3.0.12.tar.gz", hash = "sha256:18d82244ee114f543149c66a6e0c14e9c4f8a1044b5cdaadd0f82159d6a6ff59"}, 524 | ] 525 | idna = [ 526 | {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"}, 527 | {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"}, 528 | ] 529 | importlib-metadata = [ 530 | {file = "importlib_metadata-2.0.0-py2.py3-none-any.whl", hash = "sha256:cefa1a2f919b866c5beb7c9f7b0ebb4061f30a8a9bf16d609b000e2dfaceb9c3"}, 531 | {file = "importlib_metadata-2.0.0.tar.gz", hash = "sha256:77a540690e24b0305878c37ffd421785a6f7e53c8b5720d211b211de8d0e95da"}, 532 | ] 533 | importlib-resources = [ 534 | {file = "importlib_resources-3.0.0-py2.py3-none-any.whl", hash = "sha256:d028f66b66c0d5732dae86ba4276999855e162a749c92620a38c1d779ed138a7"}, 535 | {file = "importlib_resources-3.0.0.tar.gz", hash = "sha256:19f745a6eca188b490b1428c8d1d4a0d2368759f32370ea8fb89cad2ab1106c3"}, 536 | ] 537 | iniconfig = [ 538 | {file = "iniconfig-1.0.1-py3-none-any.whl", hash = "sha256:80cf40c597eb564e86346103f609d74efce0f6b4d4f30ec8ce9e2c26411ba437"}, 539 | {file = "iniconfig-1.0.1.tar.gz", hash = "sha256:e5f92f89355a67de0595932a6c6c02ab4afddc6fcdc0bfc5becd0d60884d3f69"}, 540 | ] 541 | nox = [ 542 | {file = "nox-2020.8.22-py3-none-any.whl", hash = "sha256:55f8cab16bcfaaea08b141c83bf2b7c779e943518d0de6cd9c38cd8da95d11ea"}, 543 | {file = "nox-2020.8.22.tar.gz", hash = "sha256:efa5adcf1134012f96bcd0a496ccebd4c9e9da53a831888a2a779462440eebcf"}, 544 | ] 545 | packaging = [ 546 | {file = "packaging-20.4-py2.py3-none-any.whl", hash = "sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181"}, 547 | {file = "packaging-20.4.tar.gz", hash = "sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8"}, 548 | ] 549 | pluggy = [ 550 | {file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"}, 551 | {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, 552 | ] 553 | protobuf = [ 554 | {file = "protobuf-3.13.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:9c2e63c1743cba12737169c447374fab3dfeb18111a460a8c1a000e35836b18c"}, 555 | {file = "protobuf-3.13.0-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:1e834076dfef9e585815757a2c7e4560c7ccc5962b9d09f831214c693a91b463"}, 556 | {file = "protobuf-3.13.0-cp35-cp35m-macosx_10_9_intel.whl", hash = "sha256:df3932e1834a64b46ebc262e951cd82c3cf0fa936a154f0a42231140d8237060"}, 557 | {file = "protobuf-3.13.0-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:8c35bcbed1c0d29b127c886790e9d37e845ffc2725cc1db4bd06d70f4e8359f4"}, 558 | {file = "protobuf-3.13.0-cp35-cp35m-win32.whl", hash = "sha256:339c3a003e3c797bc84499fa32e0aac83c768e67b3de4a5d7a5a9aa3b0da634c"}, 559 | {file = "protobuf-3.13.0-cp35-cp35m-win_amd64.whl", hash = "sha256:361acd76f0ad38c6e38f14d08775514fbd241316cce08deb2ce914c7dfa1184a"}, 560 | {file = "protobuf-3.13.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:9edfdc679a3669988ec55a989ff62449f670dfa7018df6ad7f04e8dbacb10630"}, 561 | {file = "protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:5db9d3e12b6ede5e601b8d8684a7f9d90581882925c96acf8495957b4f1b204b"}, 562 | {file = "protobuf-3.13.0-cp36-cp36m-win32.whl", hash = "sha256:c8abd7605185836f6f11f97b21200f8a864f9cb078a193fe3c9e235711d3ff1e"}, 563 | {file = "protobuf-3.13.0-cp36-cp36m-win_amd64.whl", hash = "sha256:4d1174c9ed303070ad59553f435846a2f877598f59f9afc1b89757bdf846f2a7"}, 564 | {file = "protobuf-3.13.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0bba42f439bf45c0f600c3c5993666fcb88e8441d011fad80a11df6f324eef33"}, 565 | {file = "protobuf-3.13.0-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:c0c5ab9c4b1eac0a9b838f1e46038c3175a95b0f2d944385884af72876bd6bc7"}, 566 | {file = "protobuf-3.13.0-cp37-cp37m-win32.whl", hash = "sha256:f68eb9d03c7d84bd01c790948320b768de8559761897763731294e3bc316decb"}, 567 | {file = "protobuf-3.13.0-cp37-cp37m-win_amd64.whl", hash = "sha256:91c2d897da84c62816e2f473ece60ebfeab024a16c1751aaf31100127ccd93ec"}, 568 | {file = "protobuf-3.13.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:3dee442884a18c16d023e52e32dd34a8930a889e511af493f6dc7d4d9bf12e4f"}, 569 | {file = "protobuf-3.13.0-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:e7662437ca1e0c51b93cadb988f9b353fa6b8013c0385d63a70c8a77d84da5f9"}, 570 | {file = "protobuf-3.13.0-py2.py3-none-any.whl", hash = "sha256:d69697acac76d9f250ab745b46c725edf3e98ac24763990b24d58c16c642947a"}, 571 | {file = "protobuf-3.13.0.tar.gz", hash = "sha256:6a82e0c8bb2bf58f606040cc5814e07715b2094caeba281e2e7d0b0e2e397db5"}, 572 | ] 573 | psutil = [ 574 | {file = "psutil-5.7.2-cp27-none-win32.whl", hash = "sha256:f2018461733b23f308c298653c8903d32aaad7873d25e1d228765e91ae42c3f2"}, 575 | {file = "psutil-5.7.2-cp27-none-win_amd64.whl", hash = "sha256:66c18ca7680a31bf16ee22b1d21b6397869dda8059dbdb57d9f27efa6615f195"}, 576 | {file = "psutil-5.7.2-cp35-cp35m-win32.whl", hash = "sha256:5e9d0f26d4194479a13d5f4b3798260c20cecf9ac9a461e718eb59ea520a360c"}, 577 | {file = "psutil-5.7.2-cp35-cp35m-win_amd64.whl", hash = "sha256:4080869ed93cce662905b029a1770fe89c98787e543fa7347f075ade761b19d6"}, 578 | {file = "psutil-5.7.2-cp36-cp36m-win32.whl", hash = "sha256:d8a82162f23c53b8525cf5f14a355f5d1eea86fa8edde27287dd3a98399e4fdf"}, 579 | {file = "psutil-5.7.2-cp36-cp36m-win_amd64.whl", hash = "sha256:0ee3c36428f160d2d8fce3c583a0353e848abb7de9732c50cf3356dd49ad63f8"}, 580 | {file = "psutil-5.7.2-cp37-cp37m-win32.whl", hash = "sha256:ff1977ba1a5f71f89166d5145c3da1cea89a0fdb044075a12c720ee9123ec818"}, 581 | {file = "psutil-5.7.2-cp37-cp37m-win_amd64.whl", hash = "sha256:a5b120bb3c0c71dfe27551f9da2f3209a8257a178ed6c628a819037a8df487f1"}, 582 | {file = "psutil-5.7.2-cp38-cp38-win32.whl", hash = "sha256:10512b46c95b02842c225f58fa00385c08fa00c68bac7da2d9a58ebe2c517498"}, 583 | {file = "psutil-5.7.2-cp38-cp38-win_amd64.whl", hash = "sha256:68d36986ded5dac7c2dcd42f2682af1db80d4bce3faa126a6145c1637e1b559f"}, 584 | {file = "psutil-5.7.2.tar.gz", hash = "sha256:90990af1c3c67195c44c9a889184f84f5b2320dce3ee3acbd054e3ba0b4a7beb"}, 585 | ] 586 | py = [ 587 | {file = "py-1.9.0-py2.py3-none-any.whl", hash = "sha256:366389d1db726cd2fcfc79732e75410e5fe4d31db13692115529d34069a043c2"}, 588 | {file = "py-1.9.0.tar.gz", hash = "sha256:9ca6883ce56b4e8da7e79ac18787889fa5206c79dcc67fb065376cd2fe03f342"}, 589 | ] 590 | pyparsing = [ 591 | {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, 592 | {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, 593 | ] 594 | pytest = [ 595 | {file = "pytest-6.1.1-py3-none-any.whl", hash = "sha256:7a8190790c17d79a11f847fba0b004ee9a8122582ebff4729a082c109e81a4c9"}, 596 | {file = "pytest-6.1.1.tar.gz", hash = "sha256:8f593023c1a0f916110285b6efd7f99db07d59546e3d8c36fc60e2ab05d3be92"}, 597 | ] 598 | pytest-cov = [ 599 | {file = "pytest-cov-2.10.1.tar.gz", hash = "sha256:47bd0ce14056fdd79f93e1713f88fad7bdcc583dcd7783da86ef2f085a0bb88e"}, 600 | {file = "pytest_cov-2.10.1-py2.py3-none-any.whl", hash = "sha256:45ec2d5182f89a81fc3eb29e3d1ed3113b9e9a873bcddb2a71faaab066110191"}, 601 | ] 602 | requests = [ 603 | {file = "requests-2.24.0-py2.py3-none-any.whl", hash = "sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898"}, 604 | {file = "requests-2.24.0.tar.gz", hash = "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b"}, 605 | ] 606 | six = [ 607 | {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"}, 608 | {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"}, 609 | ] 610 | toml = [ 611 | {file = "toml-0.10.1-py2.py3-none-any.whl", hash = "sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88"}, 612 | {file = "toml-0.10.1.tar.gz", hash = "sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f"}, 613 | ] 614 | urllib3 = [ 615 | {file = "urllib3-1.25.10-py2.py3-none-any.whl", hash = "sha256:e7983572181f5e1522d9c98453462384ee92a0be7fac5f1413a1e35c56cc0461"}, 616 | {file = "urllib3-1.25.10.tar.gz", hash = "sha256:91056c15fa70756691db97756772bb1eb9678fa585d9184f24534b100dc60f4a"}, 617 | ] 618 | virtualenv = [ 619 | {file = "virtualenv-20.0.33-py2.py3-none-any.whl", hash = "sha256:35ecdeb58cfc2147bb0706f7cdef69a8f34f1b81b6d49568174e277932908b8f"}, 620 | {file = "virtualenv-20.0.33.tar.gz", hash = "sha256:a5e0d253fe138097c6559c906c528647254f437d1019af9d5a477b09bfa7300f"}, 621 | ] 622 | zipp = [ 623 | {file = "zipp-3.3.0-py3-none-any.whl", hash = "sha256:eed8ec0b8d1416b2ca33516a37a08892442f3954dee131e92cfd92d8fe3e7066"}, 624 | {file = "zipp-3.3.0.tar.gz", hash = "sha256:64ad89efee774d1897a58607895d80789c59778ea02185dd846ac38394a8642b"}, 625 | ] 626 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | # This file is part of "pytest-austin" which is released under GPL. 2 | # 3 | # See file LICENCE or go to http://www.gnu.org/licenses/ for full license 4 | # details. 5 | # 6 | # pytest-austin is a Python wrapper around Austin, the CPython frame stack 7 | # sampler. 8 | # 9 | # Copyright (c) 2018-2020 Gabriele N. Tornetta . 10 | # All rights reserved. 11 | # 12 | # This program is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 3 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # This program is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | 24 | [tool.poetry] 25 | name = "pytest-austin" 26 | version = "0.1.0" 27 | description = "Austin plugin for pytest" 28 | license = "GPL-3.0-or-later" 29 | authors = ["Gabriele N. Tornetta "] 30 | readme = "README.md" 31 | homepage = "https://github.com/P403n1x87/pytest-austin" 32 | repository = "https://github.com/P403n1x87/pytest-austin" 33 | keywords = ["performance", "profiling", "testing", "development"] 34 | classifiers = [ 35 | "Development Status :: 4 - Beta", 36 | "Framework :: Pytest", 37 | "Intended Audience :: Developers", 38 | "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", 39 | "Programming Language :: Python :: 3.6", 40 | "Programming Language :: Python :: 3.7", 41 | "Programming Language :: Python :: 3.8", 42 | "Programming Language :: Python :: 3.9", 43 | ] 44 | packages = [ 45 | { include = "pytest_austin" }, 46 | ] 47 | 48 | [tool.poetry.plugins.pytest11] 49 | cool_plugin = "pytest_austin.plugin" 50 | 51 | [tool.poetry.dependencies] 52 | python = "^3.6" 53 | austin-python = "^0.1.0" 54 | dataclasses = "*" 55 | psutil = ">=5.7.0" 56 | ansimarkup = "^1.4.0" 57 | 58 | [tool.poetry.dev-dependencies] 59 | coverage = {extras = ["toml"], version = "5.2.1"} 60 | pytest = ">=5.4.2" 61 | pytest-cov = ">=2.8.1" 62 | nox = "^2020.5.24" 63 | codecov = "^2.1.3" 64 | 65 | [tool.poetry.urls] 66 | issues = "https://github.com/P403n1x87/pytest-austin/issues" 67 | 68 | [tool.coverage.run] 69 | branch = true 70 | source = ["pytest_austin"] 71 | 72 | [tool.coverage.report] 73 | show_missing = true 74 | 75 | [build-system] 76 | requires = ["poetry>=0.12"] 77 | build-backend = "poetry.masonry.api" 78 | -------------------------------------------------------------------------------- /pytest_austin/__init__.py: -------------------------------------------------------------------------------- 1 | from datetime import timedelta as td 2 | from functools import lru_cache 3 | import os 4 | from threading import Event 5 | from time import time 6 | from typing import Any, Dict, Iterator, List, Optional, TextIO 7 | 8 | from austin.format.pprof import PProf 9 | from austin.format.speedscope import Speedscope 10 | from austin.stats import AustinStats, Frame, FrameStats, InvalidSample, Sample 11 | from austin.threads import ThreadedAustin 12 | from psutil import Process 13 | import pytest_austin.markers as _markers 14 | 15 | 16 | Microseconds = int 17 | 18 | 19 | def _find_from_hierarchy( 20 | collector: List[FrameStats], 21 | stats_list: Dict[Frame, FrameStats], 22 | function: str, 23 | module: str, 24 | ) -> None: 25 | for label, stats in stats_list.items(): 26 | if label.function == function and label.filename.endswith(module): 27 | collector.append(stats) 28 | else: 29 | _find_from_hierarchy(collector, stats.children, function, module) 30 | 31 | 32 | def _parse_time(timedelta: Any, total_test_time: Microseconds) -> Microseconds: 33 | if isinstance(timedelta, td): 34 | return timedelta.total_seconds() * 1e6 35 | if isinstance(timedelta, str): 36 | perc = timedelta.strip() 37 | if not perc[-1] == "%": 38 | raise ValueError("Invalid % total time") 39 | return float(perc[:-1]) / 100 * total_test_time 40 | if isinstance(timedelta, float) or isinstance(timedelta, int): 41 | return timedelta 42 | 43 | raise ValueError(f"Invalid time delta type {type(timedelta)}") 44 | 45 | 46 | class PyTestAustin(ThreadedAustin): 47 | """pytest implementation of Austin.""" 48 | 49 | def __init__(self, *args: Any, **kwargs: Any) -> None: 50 | super().__init__(*args, **kwargs) 51 | 52 | self.ready = Event() 53 | self.stats = AustinStats() 54 | self.interval: str = "100" 55 | self.children = False 56 | self.mode: Optional[str] = None 57 | self.data: List[str] = [] 58 | self.global_stats: Optional[str] = None 59 | self.austinfile = None 60 | self.tests = {} 61 | self.report = [] 62 | self.report_level = "minimal" 63 | self.format = "austin" 64 | 65 | def on_ready( 66 | self, process: Process, child_process: Process, command_line: str 67 | ) -> None: 68 | """Ready callback.""" 69 | self.ready.set() 70 | 71 | def on_sample_received(self, sample: str) -> None: 72 | """Sample received callback.""" 73 | # We collect all the samples and only parse them at the end for 74 | # performance 75 | self.data.append(sample) 76 | 77 | def on_terminate(self, stats: str) -> None: 78 | """Terminate callback.""" 79 | self.global_stats = stats 80 | self.ready.set() 81 | 82 | def wait_ready(self, timeout: Optional[int] = None): 83 | """Wait for Austin to enter the ready state.""" 84 | self.ready.wait(timeout) 85 | 86 | def dump(self, stream: Optional[TextIO] = None) -> None: 87 | """Dump the collected statistics to the given IO stream. 88 | 89 | If no stream is given, the data is dumped into a file prefixed with 90 | ``.austin_`` and followed by a truncated timestamp within the pytest 91 | rootdir. 92 | """ 93 | if not self.data: 94 | return 95 | 96 | def _dump(filename, stream, dumper): 97 | if stream is None: 98 | with open( 99 | filename, "wb" if filename.endswith("pprof") else "w" 100 | ) as fout: 101 | dumper.dump(fout) 102 | self.austinfile = os.path.join(os.getcwd(), filename) 103 | else: 104 | dumper.dump(stream) 105 | 106 | def _dump_austin(): 107 | _dump(f".austin_{int((time() * 1e6) % 1e14)}.aprof", stream, self.stats) 108 | 109 | def _dump_pprof(): 110 | pprof = PProf() 111 | 112 | for line in self.data: 113 | try: 114 | pprof.add_sample(Sample.parse(line)) 115 | except InvalidSample: 116 | continue 117 | 118 | _dump(f".austin_{int((time() * 1e6) % 1e14)}.pprof", stream, pprof) 119 | 120 | def _dump_speedscope(): 121 | name = f"austin_{int((time() * 1e6) % 1e14)}" 122 | speedscope = Speedscope(name) 123 | 124 | for line in self.data: 125 | try: 126 | speedscope.add_sample(Sample.parse(line)) 127 | except InvalidSample: 128 | continue 129 | 130 | _dump(f".{name}.json", stream, speedscope) 131 | 132 | {"austin": _dump_austin, "pprof": _dump_pprof, "speedscope": _dump_speedscope}[ 133 | self.format 134 | ]() 135 | 136 | @lru_cache() 137 | def _index(self) -> Dict[str, Dict[str, FrameStats]]: 138 | # TODO: This code can be optimised. If we collect all the test items we 139 | # can index up to the test functions. Then we keep indexing whenever 140 | # we are checking eaech marked test. 141 | 142 | def _add_child_stats( 143 | stats: FrameStats, index: Dict[str, Dict[str, FrameStats]] 144 | ) -> None: 145 | """Build an index of all the functions in all the modules recursively.""" 146 | for frame, stats in stats.children.items(): 147 | index.setdefault(frame.function, {}).setdefault( 148 | frame.filename, [] 149 | ).append(stats) 150 | 151 | _add_child_stats(stats, index) 152 | 153 | index = {} 154 | 155 | for _, process in self.stats.processes.items(): 156 | for _, thread in process.threads.items(): 157 | _add_child_stats(thread, index) 158 | 159 | return index 160 | 161 | def register_test(self, function: str, module: str, markers: Iterator) -> None: 162 | """Register a test with pytest-austin. 163 | 164 | We pass the test item name and module together with any markers. 165 | """ 166 | for marker in markers: 167 | try: 168 | marker_function = getattr(_markers, marker.name) 169 | except AttributeError: 170 | continue 171 | 172 | arg_names = marker_function.__code__.co_varnames[ 173 | 1 : marker_function.__code__.co_argcount 174 | ] 175 | defaults = marker_function.__defaults__ or [] 176 | 177 | marker_args = {a: v for a, v in zip(arg_names[-len(defaults) :], defaults)} 178 | marker_args.update(marker.kwargs) 179 | marker_args.update({k: v for k, v in zip(arg_names, marker.args)}) 180 | 181 | self.tests.setdefault(function, {}).setdefault(module, []).append( 182 | marker_function((self, function, module), **marker_args) 183 | ) 184 | 185 | def _find_test(self, function: str, module: str) -> Optional[FrameStats]: 186 | # We expect to find at most one test 187 | # TODO: Match function by regex 188 | module_map = self._index().get(function, None) 189 | if module_map is None: 190 | return None 191 | 192 | matches = [module_map[k] for k in module_map if k.endswith(module)] + [None] 193 | if len(matches) > 2: 194 | RuntimeError(f"Test item {function} occurs in many matching modules.") 195 | 196 | return matches[0] 197 | 198 | def check_tests(self) -> int: 199 | """Check all the registered tests against the collected statistics. 200 | 201 | Returns the number of failed checks. 202 | """ 203 | if self.is_running(): 204 | raise RuntimeError("Austin is still running.") 205 | 206 | if not self.data: 207 | return 0 208 | 209 | # Prepare stats 210 | for sample in self.data: 211 | try: 212 | self.stats.update(Sample.parse(sample)) 213 | except InvalidSample: 214 | pass 215 | 216 | for function, modules in self.tests.items(): 217 | for module, markers in modules.items(): 218 | test_stats = self._find_test(function, module) 219 | if test_stats is None: 220 | # The test was not found. Either there is no such test or 221 | # Austin did not collect any statistics for it. 222 | continue 223 | 224 | total_test_time = sum(fs.total.time for fs in test_stats) 225 | total_test_malloc = sum( 226 | fs.total.time if self.mode == "-m" else fs.total.memory_alloc 227 | for fs in test_stats 228 | ) 229 | total_test_dealloc = ( 230 | sum(fs.total.memory_dealloc for fs in test_stats) 231 | if self.mode == "-f" 232 | else 0 233 | ) 234 | 235 | for marker in markers: 236 | outcome = marker( 237 | test_stats, 238 | total_test_time, 239 | total_test_malloc, 240 | total_test_dealloc, 241 | ) 242 | self.report.append((function, module, outcome)) 243 | 244 | return sum(1 for outcome in self.report if not outcome[2]) 245 | 246 | def start(self) -> None: 247 | """Start Austin.""" 248 | args = ["-t", "10", "-i", self.interval, "-p", str(os.getpid())] 249 | if self.mode: 250 | args.append(self.mode) 251 | if self.children: 252 | args.append("-C") 253 | 254 | super().start(args) 255 | -------------------------------------------------------------------------------- /pytest_austin/markers.py: -------------------------------------------------------------------------------- 1 | from dataclasses import dataclass 2 | from datetime import timedelta as td 3 | from typing import Any, Dict, List, NewType, Tuple, Type 4 | 5 | from ansimarkup import parse 6 | from austin.stats import Frame, FrameStats 7 | 8 | 9 | Microseconds = NewType("Microseconds", int) 10 | Bytes = NewType("Bytes", int) 11 | 12 | 13 | @dataclass 14 | class CheckOutcome: 15 | """Check outcome representation.""" 16 | 17 | mark: Tuple[str, str, int] 18 | actual: float 19 | expected: float 20 | units: Type 21 | result: bool 22 | 23 | @staticmethod 24 | def _format_size(size): 25 | if size > (1 << 30): 26 | return f"{size / (1 << 30):.1f} GB" 27 | if size > (1 << 20): 28 | return f"{size / (1 << 20):.1f} MB" 29 | if size > (1 << 10): 30 | return f"{size / (1 << 10):.1f} KB" 31 | return f"{size} B" 32 | 33 | @staticmethod 34 | def _format_time(time): 35 | if time > 1e6: 36 | return f"{time / 1e6:.1f} s" 37 | if time > 1e3: 38 | return f"{time / 1e3:.1f} ms" 39 | return f"{time:.1f} μs" 40 | 41 | def __bool__(self): 42 | """Return the outcome result.""" 43 | return self.result 44 | 45 | def __str__(self): 46 | """Give a human readable description of the outcome.""" 47 | delta = self.actual - self.expected 48 | perc = delta * 100 / self.expected 49 | 50 | function, module, line = self.mark 51 | 52 | line_mark = f":{line}" if line else "" 53 | what = f"{function}{line_mark} ({module})" 54 | 55 | formatter = {Microseconds: self._format_time, Bytes: self._format_size}[ 56 | self.units 57 | ] 58 | 59 | how_much = ( 60 | f"+{formatter(delta)}" 61 | if delta > 0 62 | else f"-{formatter(-delta)}" 63 | ) 64 | return parse( 65 | f"{what} {how_much} ({perc:.1f}% of {formatter(self.expected)})" 66 | ) 67 | 68 | 69 | def _find_from_hierarchy( 70 | collector: List[FrameStats], 71 | stats_list: Dict[Frame, FrameStats], 72 | function: str, 73 | module: str, 74 | ) -> None: 75 | for label, stats in stats_list.items(): 76 | if label.function == function and label.filename.endswith(module): 77 | collector.append(stats) 78 | else: 79 | _find_from_hierarchy(collector, stats.children, function, module) 80 | 81 | 82 | def _parse_time(timedelta: Any, total_test_time: Microseconds) -> Microseconds: 83 | try: 84 | if isinstance(timedelta, td): 85 | return timedelta.total_seconds() * 1e6 86 | if isinstance(timedelta, str): 87 | perc = timedelta.strip() 88 | if not perc[-1] == "%": 89 | raise ValueError("Invalid % total time") 90 | return float(perc[:-1]) / 100 * total_test_time 91 | if isinstance(timedelta, float) or isinstance(timedelta, int): 92 | return timedelta 93 | except ValueError: 94 | pass 95 | 96 | raise ValueError(f"Invalid time delta type {type(timedelta)}") 97 | 98 | 99 | def _parse_memory(size: Any, total_memory: Bytes) -> Bytes: 100 | try: 101 | if isinstance(size, str): 102 | _ = size.strip().upper() 103 | if _[-1] == "%": 104 | return float(_[:-1]) / 100 * total_memory 105 | if _.endswith("GB"): 106 | return int(_[:-2]) << 30 107 | if _.endswith("MB"): 108 | return int(_[:-2]) << 20 109 | if _.endswith("KB"): 110 | return int(_[:-2]) << 10 111 | if _.endswith("B"): 112 | return int(_[:-2]) 113 | if isinstance(size, int): 114 | return size 115 | except ValueError: 116 | pass 117 | 118 | raise ValueError(f"Invalid memory size format or type {type(size)}") 119 | 120 | 121 | def total_time(mark, time, function=None, module=None, line=0): 122 | """ 123 | Check that the marked line doesn't take more than the given time delta to 124 | execute. If no line is given, then the whole function is considered. 125 | """ 126 | _, test_function, test_module = mark 127 | function = function or test_function 128 | module = module or test_module 129 | 130 | def _(test_stats, total_test_time, total_test_malloc, total_test_dealloc): 131 | # find by function and module from index 132 | function_stats = [] 133 | _find_from_hierarchy( 134 | function_stats, {s.label: s for s in test_stats}, function, module, 135 | ) 136 | 137 | if line: 138 | function_stats = [fs for fs in function_stats if fs.label.line == line] 139 | 140 | function_total_time = sum(fs.total.time for fs in function_stats) 141 | 142 | expected_time = _parse_time(time, total_test_time) 143 | outcome = function_total_time <= expected_time 144 | 145 | return CheckOutcome( 146 | mark=(function, module, line), 147 | actual=function_total_time, 148 | expected=expected_time, 149 | units=Microseconds, 150 | result=outcome, 151 | ) 152 | 153 | return _ 154 | 155 | 156 | def total_memory(mark, size, function=None, module=None, line=0, net=False): 157 | """ 158 | Check that the marked line doesn't allocate more than the given memory to 159 | execute. If no line is given, then the whole function is considered. If net 160 | is set to ``True`` it will consider the net memory usage, that is the sum 161 | between memory allocations and deallocations. 162 | """ 163 | pytest_austin, test_function, test_module = mark 164 | function = function or test_function 165 | module = module or test_module 166 | 167 | def _(test_stats, total_test_time, total_test_malloc, total_test_dealloc): 168 | # find by function and module from index 169 | function_stats = [] 170 | _find_from_hierarchy( 171 | function_stats, {s.label: s for s in test_stats}, function, module, 172 | ) 173 | 174 | if line: 175 | function_stats = [fs for fs in function_stats if fs.label.line == line] 176 | 177 | function_total_alloc = sum( 178 | fs.total.time if pytest_austin.mode == "-m" else fs.total.memory_alloc 179 | for fs in function_stats 180 | ) 181 | function_total_dealloc = sum(fs.total.memory_dealloc for fs in function_stats) 182 | 183 | total_memory = ( 184 | total_test_malloc if not net else total_test_malloc + total_test_dealloc 185 | ) 186 | function_memory = ( 187 | function_total_alloc 188 | if not net 189 | else function_total_alloc + function_total_dealloc 190 | ) 191 | expected_memory = _parse_memory(size, total_memory) 192 | outcome = function_memory <= expected_memory 193 | 194 | return CheckOutcome( 195 | mark=(function, module, line), 196 | actual=function_memory, 197 | expected=expected_memory, 198 | units=Bytes, 199 | result=outcome, 200 | ) 201 | 202 | return _ 203 | -------------------------------------------------------------------------------- /pytest_austin/plugin.py: -------------------------------------------------------------------------------- 1 | from austin import AustinTerminated 2 | from pytest import Function, hookimpl, Module 3 | from pytest_austin import PyTestAustin 4 | import pytest_austin.markers as markers 5 | 6 | 7 | def pytest_addoption(parser, pluginmanager) -> None: 8 | """Add Austin command line options to pytest.""" 9 | group = parser.getgroup("austin", "statistical profiling with Austin") 10 | 11 | group.addoption( 12 | "--steal-mojo", 13 | action="store_true", 14 | default=False, 15 | help="Disable Austin profiling", 16 | ) 17 | 18 | group.addoption( 19 | "--profile-mode", 20 | choices=["time", "memory", "all"], 21 | default="time", 22 | help="The profile mode. Defaults to 'time'", 23 | ) 24 | 25 | group.addoption( 26 | "--sampling-interval", 27 | type=int, 28 | default=100, 29 | help="Austin sampling interval in μs. Defaults to 100 μs", 30 | ) 31 | 32 | group.addoption( 33 | "--minime", 34 | action="store_true", 35 | default=False, 36 | help="Profile any child processes too", 37 | ) 38 | 39 | group.addoption( 40 | "--profile-format", 41 | choices=["austin", "speedscope", "pprof"], 42 | default="austin", 43 | help="Output profiler data file format. Defaults to 'austin'", 44 | ) 45 | 46 | group.addoption( 47 | "--austin-report", 48 | choices=["minimal", "full"], 49 | default="minimal", 50 | help="The verbosity of the Austin checks report. By default, only failed" 51 | "checks are reported.", 52 | ) 53 | 54 | 55 | def pytest_configure(config) -> None: 56 | """Configure pytest-austin.""" 57 | # Register all markers 58 | for _ in dir(markers): 59 | _ = getattr(markers, _) 60 | 61 | if not callable(_): 62 | continue 63 | 64 | try: 65 | args = _.__code__.co_varnames 66 | if not args or args[0] != "mark": 67 | continue 68 | except AttributeError: 69 | # We cannot get the argument names, so not a marker 70 | continue 71 | 72 | config.addinivalue_line( 73 | "markers", f"{_.__name__}({', '.join(args[1:])}):{_.__doc__}" 74 | ) 75 | 76 | if config.option.steal_mojo: 77 | # No mojo :( 78 | return 79 | 80 | # Required for when testing with pytester in-process 81 | pytest_austin = PyTestAustin() 82 | 83 | if config.option.profile_mode != "time": 84 | pytest_austin.mode = {"memory": "-m", "all": "-f"}[config.option.profile_mode] 85 | 86 | pytest_austin.interval = str(config.option.sampling_interval) 87 | pytest_austin.children = config.option.minime 88 | pytest_austin.report_level = config.option.austin_report 89 | pytest_austin.format = config.option.profile_format 90 | 91 | config.pluginmanager.register(pytest_austin, "austin") 92 | 93 | 94 | def pytest_sessionstart(session) -> None: 95 | """Start Austin if we have mojo.""" 96 | pytest_austin = session.config.pluginmanager.getplugin("austin") 97 | if not pytest_austin: 98 | return 99 | 100 | pytest_austin.start() 101 | pytest_austin.wait_ready(1) 102 | 103 | 104 | def pytest_runtest_setup(item) -> None: 105 | """Register tests and checks with pytest-austin.""" 106 | pytest_austin = item.config.pluginmanager.getplugin("austin") 107 | if not pytest_austin: 108 | return 109 | 110 | if pytest_austin.is_running(): 111 | if isinstance(item, Function) and isinstance(item.parent, Module): 112 | function, module = item.name, item.parent.name 113 | pytest_austin.register_test( 114 | function, module, item.iter_markers(), 115 | ) 116 | 117 | 118 | @hookimpl(hookwrapper=True) 119 | def pytest_runtestloop(session): 120 | """Run all checks at the end and set the exit status.""" 121 | yield 122 | 123 | # This runs effectively at the end of the session 124 | pytest_austin = session.config.pluginmanager.getplugin("austin") 125 | if not pytest_austin: 126 | return 127 | 128 | if pytest_austin.is_running(): 129 | pytest_austin.terminate(wait=True) 130 | 131 | try: 132 | pytest_austin.join() 133 | except AustinTerminated: 134 | pass 135 | 136 | session.testsfailed += pytest_austin.check_tests() 137 | 138 | pytest_austin.dump() 139 | 140 | 141 | def pytest_terminal_summary(terminalreporter, exitstatus, config) -> None: 142 | """Report Austin statistics if we had mojo.""" 143 | pytest_austin = config.pluginmanager.getplugin("austin") 144 | if not pytest_austin: 145 | return 146 | 147 | terminalreporter.write_sep("=", "Austin report") 148 | terminalreporter.write_line(f"austin {pytest_austin.version}") 149 | if not pytest_austin.data: 150 | terminalreporter.write_line("No data collected.") 151 | return 152 | 153 | if pytest_austin.austinfile is not None: 154 | terminalreporter.write_line( 155 | f"Collected stats written on {pytest_austin.austinfile}\n" 156 | ) 157 | 158 | if pytest_austin.global_stats: 159 | terminalreporter.write_line(pytest_austin.global_stats + "\n") 160 | else: 161 | terminalreporter.write_line( 162 | f"Austin collected a total of {len(pytest_austin.data)} samples\n" 163 | ) 164 | 165 | # Report failed Austin conditions 166 | checks = pytest_austin.report 167 | failed_checks = [check for check in checks if not check[2]] 168 | if pytest_austin.report_level == "minimal": 169 | checks = failed_checks 170 | 171 | if checks: 172 | n = len(failed_checks) 173 | 174 | for function, module, outcome in checks: 175 | terminalreporter.write_line(f"{module}::{function} {outcome}") 176 | 177 | terminalreporter.write_line("") 178 | terminalreporter.write_sep( 179 | "=", f"{n} check{'s' if n > 1 else ''} failed", red=True, bold=True, 180 | ) 181 | terminalreporter.write_line("") 182 | -------------------------------------------------------------------------------- /test/conftest.py: -------------------------------------------------------------------------------- 1 | pytest_plugins = ["pytester"] 2 | -------------------------------------------------------------------------------- /test/test_pytest_austin.py: -------------------------------------------------------------------------------- 1 | from datetime import timedelta as td 2 | import os 3 | import os.path 4 | 5 | from pytest_austin import _parse_time 6 | 7 | 8 | def check_austin_dump(dir, needle): 9 | """Check that we have produced a profiler dump.""" 10 | # We expect a single austin file 11 | (austin_file,) = [file for file in os.listdir(dir) if file.startswith(".austin")] 12 | assert austin_file 13 | 14 | with open( 15 | os.path.join(dir, austin_file), "rb" if austin_file.endswith(".pprof") else "r" 16 | ) as fin: 17 | assert needle in fin.read() 18 | 19 | 20 | def test_parse_time(): 21 | assert _parse_time(td(microseconds=10), 0) == 10 22 | 23 | 24 | def test_austin_time_checks(testdir): 25 | """Test Austin time checks.""" 26 | 27 | # create a temporary pytest test file 28 | testdir.makepyfile( 29 | """ 30 | from datetime import timedelta as td 31 | from time import sleep 32 | 33 | import pytest 34 | 35 | def hello(name="World"): 36 | return "Hello {name}!".format(name=name) 37 | 38 | def fibonacci(n): 39 | if n in (0, 1): 40 | return 1 41 | return fibonacci(n-1) + fibonacci(n-2) 42 | 43 | @pytest.mark.total_time(td(milliseconds=50), function="fibonacci") 44 | @pytest.mark.total_time("99 %", line=18) 45 | @pytest.mark.total_time("50.3141592653 %", line=19) 46 | def test_lines(): 47 | fibonacci(27) 48 | fibonacci(25) 49 | 50 | @pytest.mark.total_time(td(microseconds=1000)) 51 | def test_check_fails(): 52 | sleep(.1) 53 | assert hello() == "Hello World!" 54 | 55 | @pytest.mark.total_time(td(milliseconds=110)) 56 | def test_check_succeeds(): 57 | sleep(.1) 58 | assert hello() == "Hello World!" 59 | """ 60 | ) 61 | 62 | result = testdir.runpytest("-vs", "--austin-report", "full") 63 | 64 | assert result.ret > 0 65 | 66 | check_austin_dump(testdir.tmpdir, "test_lines") 67 | 68 | 69 | def test_austin_memory_checks(testdir): 70 | """Test Austin memory checks.""" 71 | 72 | # create a temporary pytest test file 73 | testdir.makepyfile( 74 | """ 75 | import pytest 76 | 77 | @pytest.mark.total_memory("50.3141592653 %") 78 | def test_memory_alloc_fails(): 79 | a = [42] 80 | for i in range(20): 81 | a = list(a) + list(a) 82 | 83 | @pytest.mark.total_memory("128 MB") 84 | def test_memory_alloc_succeeds(): 85 | a = [42] 86 | for i in range(20): 87 | a = list(a) + list(a) 88 | 89 | @pytest.mark.total_memory("12 MB", net=True) 90 | def test_memory_net_alloc(): 91 | a = [42] 92 | for i in range(20): 93 | a = list(a) + list(a) 94 | 95 | """ 96 | ) 97 | 98 | result = testdir.runpytest( 99 | "-vs", "--profile-mode", "memory", "--profile-format", "pprof" 100 | ) 101 | 102 | assert result.ret > 0 103 | 104 | check_austin_dump(testdir.tmpdir, b"test_memory_alloc") 105 | 106 | 107 | def test_austin_full_checks(testdir): 108 | """Test Austin full checks.""" 109 | 110 | # create a temporary pytest test file 111 | testdir.makepyfile( 112 | """ 113 | import pytest 114 | 115 | @pytest.mark.total_time(1) 116 | @pytest.mark.total_memory("1 KB") 117 | def test_full_checks_fails(): 118 | a = [42] 119 | for i in range(20): 120 | a = list(a) + list(a) 121 | """ 122 | ) 123 | 124 | result = testdir.runpytest( 125 | "-vs", "--profile-mode", "all", "--profile-format", "speedscope" 126 | ) 127 | 128 | assert result.ret > 0 129 | 130 | check_austin_dump(testdir.tmpdir, "test_full_checks") 131 | --------------------------------------------------------------------------------