Skip to content

Commit

Permalink
Document rules
Browse files Browse the repository at this point in the history
  • Loading branch information
David Cramer committed Jul 26, 2013
1 parent 12d1501 commit d4be8d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.rst
Expand Up @@ -39,3 +39,19 @@ Or, if you'd prefer, via ``setup.cfg``::
quickunit-prefix = tests/unit
tests/integration
quickunit-rule = tests/{path}/test_{filename}

Rules
-----

Rules are a combination of simple formatting a regular expressions.

The following formatted variables are available within a rule:

{path}
The base path of the filename (e.g. foo/bar)
{filename}
The filename excluding the path (e.g. baz.py)
{basename}
The filename excluding the extension (e.g. baz)

A rule is first formatted (using ``.format(params)``) and then compiled into a regular expression on top of each changed file.
4 changes: 4 additions & 0 deletions quickunit/plugin.py
Expand Up @@ -54,9 +54,13 @@ def compile(self):
path, filename = filepath.rsplit('/', 1)
except ValueError:
path, filename = '', filepath

basename = filename.rsplit('.', 1)[0]

params = {
'path': path,
'filename': filename,
'basename': basename,
}
for rule in self.rules:
rules.append(re.compile(rule.format(**params)))
Expand Down

0 comments on commit d4be8d7

Please sign in to comment.