tests module

The pychangelog.tests module provides some helper functions and classes for testing your changelog, as well as standard version modules.

A standard version module is simply a module which you distribute as part of your package (usually called package_name.version) which includes as public members a certain set of standard attributes providing information about the version number of the package. Specifically, it provides the following attributes, which you can read more about in this package’s version module:

Nosetests

Some of the code in this module is intended to work with the nose test utility for python. While none of it strictly depends on nose to function, the node python package will be imported and used to provide some additional convenience if it is available.

pychangelog.tests.verify_version_module(changelog, version)[source]

Generically tests the contents of a standard version module against the contents of the given ChangeLog object, without any pre-existing assumptions about whether or not this is for a release or a development version.

The latest full release (i.e., not a pre-release) in the changelog should correspond to the version and date information in the version module. If there is not full release in the change log, then the version module should list major version 0 and release 0.

Additionally, if the change-log has no pre-release, then we should not be in development mode, meaning version.SUFFIX should be None. Otherwise, it should not be None.

pychangelog.tests.verify_for_release(changelog, version)[source]

Tests a version module and change log for a release version. This calls verify_version_module to do the generic tests validating the version module against the changelog, and also tests that the version module and changelog are both correct for a release version.

pychangelog.tests.verify_for_development(changelog, version)[source]

Tests a version module and change log for a release version. This calls verify_version_module to do the generic tests validating the version module against the changelog, and also tests that the version module and changelog are both correct for a release version.

class pychangelog.tests.StandardVersionTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

This is a simple TestCase class that can be easily extended for unittesting to validate your changelog and version module. All you need to do is subclass this class and set the version_mod attribute to the module which contains your project’s standard version attributes.

Alternatively, you can use the create factory method to create automatically create a new subclass with the specified version module.

See also

  • get_path_to_changelog can be overridden to change the path from which

    the changelog will be read.

  • get_changelog can be overridden to change the way in which the changelog

    is actually loaded and parsed.

  • get_version_module can be overridden to change the way the version module

    is fetched, instead of just getting it form the version_mod attribute.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

classmethod create(version_mod)[source]

Create and return a new subclass of cls which sets the version_mod attribute to the given version module. This is an alternative to statically subclassing if for some reason that’s easier for you.

version_mod = None

The version_mod attribute should be set on a subclass of StandardVersionTests to the module which implememnts your package’s standard version attributes.

get_path_to_changelog()[source]

Returns the filesystem path from which the changelog will be read by get_changelog.

get_changelog()[source]

Called from setUp to get a ChangeLog object to test with. The default implementation opens the path indicates by get_path_to_changelog and parses it using parse_plain_text.

get_version_module()[source]

Should returns a module which implements your projects standard version attributes. The default implementation returns the value of the version_mod attribute, which subclasses can easily set statically in the class definition.

If this attribute value is None, will raise a NotImplementedError. This is what will happen if you actually try to run an instance of this class directly, instead of subclassing it to override the value of the version_mod attribute.

setUp()[source]

Test setup sets a change_log attribute on the instance to the value returned by get_changelog.

test_changelog()[source]

Just does the setUp to make sure that the changelog can be parsed and constructed.

test_version_module()[source]

Invokes verify_version_module.

test_for_release()[source]

Invokes verify_for_release.

If nose is installed, this is tagged with the attribute release using the attrib plugin. To omit this test, you can invoke nosetests using the --attr parameter, for instance in BASH as:

$ nosetest --attr '!release'

or in DOS as:

> nosetests --attr !release
test_for_dev()[source]

Invokes verify_for_development.

If nose is installed, this is tagged with the attribute dev using the attrib plugin. To omit this test, you can invoke nosetests using the --attr parameter, for instance in BASH as:

$ nosetest --attr '!dev'

or in DOS as:

> nosetests --attr !dev