-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31e674d
commit a4f2aa4
Showing
3 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
# You can import from the package any way you want. | ||
# Test a function that is intended to be used by the end user. | ||
from rain import this_function_will_be_imported | ||
|
||
# Test a function that is NOT intended to be used by the end user. | ||
from rain.directory_module_with_selective_imports.utils import helper_function_1 | ||
|
||
|
||
def test_end_user_usable(): | ||
assert isinstance(this_function_will_be_imported(), str) | ||
|
||
|
||
def test_helper_function_1(): | ||
assert helper_function_1() == 'helper_function_1' |
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,27 @@ | ||
import pytest | ||
|
||
|
||
class TestClassNoConstructor: | ||
# Setup anything that you need to test. | ||
x = 1 | ||
|
||
def test_x_is_one(self): | ||
# Change this to `assert 1 == 2` to see that this method is indeed being tested | ||
assert self.x == 1 | ||
|
||
|
||
class TestClassWithConstructor: | ||
# Having a constructor means that this class won't be tested. Instead, you will see this warning: | ||
# | ||
# PytestCollectionWarning: cannot collect test class 'TestClassWithConstructor' because it has a | ||
# __init__ constructor (from: tests/test_using_a_class.py) | ||
# class TestClassWithConstructor: | ||
# | ||
# -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html | ||
def __init__(self, x: int): | ||
self.x = int(x) | ||
|
||
def test_will_not_run(self): | ||
# This test won't run because this class has a constructor | ||
assert 1 == 2 | ||
|