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
import pytest | |
@pytest.fixture | |
def first(): | |
print("Set up first fixture") | |
yield | |
print("Clean up first fixture") | |
@pytest.fixture |
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
import pytest | |
def process_file(fp): | |
"""Toy function that returns an array of line lengths.""" | |
return [len(l.strip()) for l in fp.readlines()] | |
@pytest.mark.parametrize("filename, expected", [ | |
("first.txt", [3, 3, 3]), |
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
import pytest | |
def divide(a, b): | |
return a / b | |
@pytest.mark.parametrize("a, b, expected, is_error", [ | |
(1, 1, 1, False), | |
(42, 1, 42, False), |
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 copy import deepcopy | |
import pytest | |
@pytest.fixture | |
def alex(): | |
return { | |
"name": "Alex", | |
"team": "Green", |
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
"""Add this to <project-root>/mocker_over_mock.py""" | |
import pytest | |
try: | |
import mock # fails on Python 3 | |
except ImportError: | |
from unittest import mock | |
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
"""Add this to <project-root>/mocker_over_mock.py""" | |
import pytest | |
try: | |
import mock # fails on Python 3 | |
except ImportError: | |
from unittest import mock | |
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
> nwml train | |
Starting local training for nwpy-ml-iris | |
Loading the ml.train entry point... | |
* Success! | |
... | |
Done! | |
> nwml batch-predict | |
... | |
Done! |