Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
Improved docs. Fixed issue of None package name.
Browse files Browse the repository at this point in the history
  • Loading branch information
yni6 committed Mar 25, 2015
1 parent efdf253 commit 27d1ccf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ suites:

Notes of the configuration:
* Name of a suite or a group could be anything you like.
* **package**: A dotted package name implying the directory of your test .py files. The tests in one suite have to be in the same package. To collect tests in another package, define another suite.
* **package**: A dotted path (relative to PYTHONPATH) indicating the python package where your test .py files locate. The tests in one suite have to be in the same package. To collect tests in another package, define another suite. However tests in one package can be divided into several suites.
* **granularity**: One of 'module', 'class' and 'method'.
* **modules**: A list of module names (test file names with .py trimmed). Only takes effect when granularity is 'module'.
* **classes**: A list of dotted class names conforming to 'module.class'. Only takes effect when granularity is 'class'.
Expand Down Expand Up @@ -247,4 +247,4 @@ Results:
9 x 9 = 81
```

For more examples, please see <code>example/</code>.
For more examples, please see <code>example/</code>. To run the examples, please read <code>example/read_me.txt</code> first.
5 changes: 5 additions & 0 deletions example/read_me.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ This directory contains examples of how to use unishark data driven tests
and configuration files. The tests include examples of assertions and
failing tests.

To run the example:
1. pip install Jinja2 unishark.
2. assume you copied 'example' to /your/dir/, cd /your/dir/example
3. PYTHONPATH=.. python run_tests.py (or export PYTHONPATH=/your/dir, then python run_tests.py)

Use run_tests.py to run a defined set of tests across several classes
or run any of the individual test_module*.py classes. Note that some
tests in test_module2.py are expected to fail.
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@

here = path.abspath(path.dirname(__file__))
NAME = 'unishark'
VERSION = __import__(NAME).VERSION
VERSION = '0.1.1'

setup(
name=NAME,
version=VERSION,

description='A lightweight unittest extension that provides reports, suites config and other test utilities.',
long_description='''unishark extends unittest (to be more accurate, unittest2) in the following ways:
- Generating polished test reports in different formats such as HTML, XUnit, etc..
- Organizing test suites with dictionary config (or yaml/json like config).
- Offering test utils such as data-driven decorator to accelerate tests writing.
3rd party dependencies: Jinja2, MarkupSafe.
Extending existent unittest code with one or more unishark features is easy.
For more information please see README.md on the project home page on github.''',

Expand Down
6 changes: 4 additions & 2 deletions unishark/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def _parse_tests_from_dict(self, dict_conf):
for suite_name, suite in suites_dict.items():
if 'disable' in suite and suite['disable']:
continue
pkg_name = suite['package'] if 'package' in suite else None
pkg_name = None
if 'package' in suite and suite['package']:
pkg_name = suite['package']
groups_dict = suite['groups']
test_cases_names = []
for group_key, group in groups_dict.items():
Expand Down Expand Up @@ -85,7 +87,7 @@ def _parse_tests_from_dict(self, dict_conf):
test_cases_names.extend(full_mth_names)
else:
raise ValueError('Granularity must be in %r.' % ['module', 'class', 'method'])
res_suites[suite_name] = {'package': pkg_name, 'test_case_names': set(test_cases_names)}
res_suites[suite_name] = {'package': pkg_name or 'None', 'test_case_names': set(test_cases_names)}
log.info('Parsed test config successfully.')
return res_suites

Expand Down

0 comments on commit 27d1ccf

Please sign in to comment.