unit test generator for Python
Project description
Installation
Easiest way to get Pythoscope is via setuptools:
$ easy_install pythoscope
You can also download a source package from http://pythoscope.org/local–files/download/pythoscope-0.4.3.tar.gz or get a copy of a development branch using bazaar:
$ bzr branch lp:pythoscope
To install the package from the source directory do:
$ python setup.py install
You don’t need setuptools for this to work, a bare Python will do just fine.
However, if you do have setuptools installed, you may also consider running the whole test suite of Pythoscope:
$ python setup.py test
Usage
You can use the tool through a single pythoscope command. To prepare your project for use with Pythoscope, type:
$ pythoscope --init path/to/your/project/
It’s only doing static analysis, and doesn’t import your modules or execute your code in any way, so you’re perfectly safe to run it on anything you want. After that, a directory named .pythoscope will be created in the current directory. To generate test stubs based on your project, select files you want to generate tests for:
$ pythoscope path/to/your/project/specific/file.py path/to/your/project/other/*.py
Test files will be saved to your test directory, if you have one, or into a new tests/ directory otherwise. Test cases are aggregated into TestCase classes. Currently each production class and each production function gets its own TestCase class.
Some of the classes and functions are ignored by the generator - all which name begins with an underscore, exception classes, and some others.
Generator itself is configurable to some extent, see:
$ pythoscope --help
for more information on available options.
Editor Integration
Emacs
We put out an elisp script that integrates Pythoscope into Emacs. The file is in the the misc/ directory of the source distribution. You can also look at the file on Launchpad. Usage and installation instructions are in the comments at the top of the file.
Vim
There is interest in Vim integration and someone is working on it but we have nothing for you right now.
Leo
There was much discussion of Leo on the mail list editor integration thread.
License
All Pythoscope source code is licensed under an MIT license (see LICENSE file). All files under lib2to3/ are licensed under PSF license.
Changelog
0.4.3
Pythoscope now ignores application and test modules it could not inspect (#487138 #462849).
Improved generation of assertions for functions with varargs and kwargs (#475414 #475409).
Pythoscope will no longer generate two test cases with the same name (#475504).
Installation package now contains all essential files (#481238).
Pythoscope now properly handles string exceptions thrown inside entry points (#522364).
Entry points are now run with the current directory being the project root (#524352).
0.4.2
Removed dependency on fixture module.
Fixed test generation bug related to function definitions with varargs (#440773).
Dynamic inspector can now handle all types of exceptions (including string exceptions).
Frequently Asked Questions document has been created, also available online.
New imports added by Pythoscope are now placed after existing ones, so they don’t cause a syntax error when __future__ imports were used (#373978).
Fixed inspection bug related to classes deriving from namedtuple instances (#460715).
0.4.1
Greatly improved information storage performance.
Added Pythoscope module for Emacs to the misc/ directory in the source tree.
Unittests can now be used as points of entry (#275059).
Pythoscope now ignores source control files (#284568).
Static inspection happens on –init, as it should be (#325928).
Ported itertive pattern matcher for lib2to3 from Python trunk (#304541).
Fixed test generation bug related to nested function arguments (#344220).
Fixed point of entry cleanup bug (#324522).
Fixed some more Windows-specific bugs (#348136).
0.4
Stopped using pickle for object serialization and implemented our own mechanism that carefully captures changing state of objects during dynamic inspection.
Implemented preserve objects identity blueprint.
Fixed bug related to multiple generator calls (#295340).
Made handling of special method names (like __init__ or __eq__) consistent with handling of normal method names.
Made test stubs more useful.
0.3.2
Made Pythoscope more verbose.
Fixed unicode handling bug (#284585).
Improved performance of the internal information storage.
0.3.1
0.3
Fixed generate bug for test modules (#264449).
.pythoscope became a directory.
Introduced –init option for initializing .pythoscope/ directory.
Added a notion of points of entry introducing dynamic analysis.
Pythoscope can now generate assert_equal and assert_raises type of assertions.
Implemented no more inspect command blueprint.
Changed the default test directory from pythoscope-tests/ to tests/.
Added a tutorial to the README file.
0.2.2
Fixed the inner classes bug (#260924).
Collector appends new data to .pythoscope file instead of overwriting it.
Test modules are being analyzed as well.
Using lib2to3 for static code analysis instead of stdlib’s compiler module.
Generator can append test cases to existing test modules. Preserves comments and original whitespace.
Cheetah is no longer a dependency.
Renamed ‘collect’ command to ‘inspect’.
0.2.1
Contains a packaging bug fix, which prevented users from using the tests cases generator and running internal pythoscope tests.
0.2
First release, featuring static code analysis and generation of test stubs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pythoscope-0.4.3.tar.gz
.
File metadata
- Download URL: pythoscope-0.4.3.tar.gz
- Upload date:
- Size: 112.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14fdc6e7f7d7738cc1cb5d99bb74062d0071f7c400583df41172a70be69fa864 |
|
MD5 | 15ddb693097375002fecd343d305f17f |
|
BLAKE2b-256 | 86538d1bad3ea1bc2f69e8b39e10c0542cc907e6e8e537327f6c6e9298a8d3c4 |