Last active
April 27, 2020 01:52
-
-
Save FND/4563578 to your computer and use it in GitHub Desktop.
minimal pytest example
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
*.pyc |
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
# empty |
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
.PHONY: test clean | |
test: clean | |
py.test -s --tb=short tests | |
clean: | |
find . -name "*.pyc" | xargs rm || true | |
rm -rf test/__pycache__ # pytest |
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
def convert(txt): | |
return "<%s>" % txt.upper() |
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
from sample import convert | |
def setup_module(module): | |
print "\n==== setting up ====\n" | |
def teardown_module(module): | |
print "\n==== tearing down ====\n" | |
def test_conversion(): | |
assert convert("hello world") == "<HELLO WORLD>" | |
assert True == False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment