This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from darrenburns/test-annotation
Descriptive testing
- Loading branch information
Showing
21 changed files
with
932 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from modulefinder import ModuleFinder | ||
from pkgutil import ModuleInfo | ||
|
||
from ward import test, fixture, expect, raises | ||
from ward.collect import search_generally, is_test_module | ||
from ward.testing import Test | ||
|
||
|
||
def named(): | ||
expect("fox").equals("fox") | ||
|
||
|
||
@fixture | ||
def named_test(): | ||
return Test(fn=named, module_name="my_module") | ||
|
||
|
||
@fixture | ||
def tests_to_search(named_test): | ||
return [named_test] | ||
|
||
|
||
@test("search_generally matches on qualified test name") | ||
def _(tests_to_search, named_test): | ||
results = search_generally(tests_to_search, query="my_module.named") | ||
expect(list(results)).equals([named_test]) | ||
|
||
|
||
@test("search_generally matches on test name alone") | ||
def _(tests_to_search, named_test): | ||
results = search_generally(tests_to_search, query="named") | ||
expect(list(results)).equals([named_test]) | ||
|
||
|
||
@test("search_generally query='fox' returns tests with 'fox' in the body") | ||
def _(tests_to_search, named_test): | ||
results = search_generally(tests_to_search, query="fox") | ||
expect(list(results)).equals([named_test]) | ||
|
||
|
||
@test("search_generally returns an empty generator when no tests match query") | ||
def _(tests_to_search): | ||
results = search_generally(tests_to_search, query="92qj3f9i") | ||
with raises(StopIteration): | ||
next(results) | ||
|
||
|
||
@test("is_test_module returns True when module name begins with 'test_'") | ||
def _(): | ||
module = ModuleInfo(ModuleFinder(), "test_apples", False) | ||
expect(is_test_module(module)).equals(True) | ||
|
||
|
||
@test("is_test_module returns False when module name doesn't begin with 'test_'") | ||
def _(): | ||
module = ModuleInfo(ModuleFinder(), "apples_test", False) | ||
expect(is_test_module(module)).equals(False) |
Oops, something went wrong.