Skip to content

Commit

Permalink
added samples as a module to conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
Sri Tikkireddy committed Sep 17, 2024
1 parent b17590c commit 63c085c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import sys
from pathlib import Path


def add_samples_to_path():
samples_dir = str(Path(__file__).parent / "samples")

if samples_dir not in sys.path:
sys.path.append(samples_dir)

if "PYTHONPATH" in os.environ:
os.environ["PYTHONPATH"] = f"{os.environ['PYTHONPATH']}:{samples_dir}"
else:
os.environ["PYTHONPATH"] = samples_dir


def pytest_sessionstart(session):
add_samples_to_path()
8 changes: 4 additions & 4 deletions tests/functions/test_function_deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

def test_register_no_op_behavior():
uc = FunctionDeployment("foo", "bar", root_dir=samples_dir)
from tests.samples.redact import redact
from samples.redact import redact

reg = uc.register(redact)

Expand Down Expand Up @@ -94,7 +94,7 @@ def test_register_no_op_behavior():

def test_register_secret_behavior():
uc = FunctionDeployment("foo", "bar", root_dir=samples_dir)
from tests.samples.redact_with_secret import redact_w_secret
from samples.redact_with_secret import redact_w_secret

reg = uc.register(redact_w_secret)

Expand All @@ -118,7 +118,7 @@ def test_remote():
"bar",
root_dir=samples_dir,
)
from tests.samples.redact import redact
from samples.redact import redact

reg = uc.register(redact)
data = '{"foo": "bar"}'
Expand All @@ -137,7 +137,7 @@ def test_remote():

def test_deploy():
uc = FunctionDeployment("foo", "bar", root_dir=samples_dir)
from tests.samples.redact import redact
from samples.redact import redact

uc.register(redact)

Expand Down
4 changes: 2 additions & 2 deletions tests/inline/test_recursive_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


def test_inline():
from tests.samples.redact import redact
from samples.redact import redact

inline_function(redact, samples_dir)
assert redact._inlined == True, "Function was not inlined"
Expand All @@ -43,7 +43,7 @@ def test_inline():


def test_undefined_names():
from tests.samples.redact_with_undefined_name import redact_undefined
from samples.redact_with_undefined_name import redact_undefined

with pytest.raises(ValueError) as e:
inline_function(redact_undefined, samples_dir)
Expand Down
Empty file added tests/samples/__init__.py
Empty file.

0 comments on commit 63c085c

Please sign in to comment.