Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/pytest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ py_library(

py_pytest_main(
name = "__test__",
chdir = package_name(), # So that test fixtures are available at the correct path
deps = [
"@pypi_coverage//:pkg",
"@pypi_pytest//:pkg",
Expand All @@ -24,6 +25,9 @@ py_test(
imports = ["../.."],
main = ":__test__.py",
package_collisions = "warning",
data = glob([
"fixtures/*.json",
]),
deps = [
":__test__",
":lib",
Expand All @@ -43,6 +47,9 @@ py_test(
imports = ["../.."],
main = ":__test__.py",
package_collisions = "warning",
data = glob([
"fixtures/*.json",
]),
deps = [
":__test__",
":lib",
Expand Down
3 changes: 3 additions & 0 deletions examples/pytest/fixtures/hello.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"message": "Hello, world."
}
6 changes: 6 additions & 0 deletions examples/pytest/foo_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import pytest
import json

from examples.pytest.foo import add

def test_add():
assert add(1, 1) == 2, "Expected 1 + 1 to equal 2"

def test_hello_json():
content = open('fixtures/hello.json', 'r').read()
data = json.loads(content)
assert data["message"] == "Hello, world.", "Message is as expected"
Loading