1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
import sys
from pathlib import Path
import pytest
from briefcase.console import LogLevel
PYTHONPATH = "PYTHONPATH"
PYTHONMALLOC = "PYTHONMALLOC"
@pytest.mark.skipif(sys.platform != "win32", reason="Relevant only for windows")
def test_pythonpath_with_one_source_in_windows(dev_command, first_app):
"""Test get environment with one source."""
env = dev_command.get_environment(first_app, test_mode=False)
assert env[PYTHONPATH] == f"{Path.cwd() / 'src'}"
assert env[PYTHONMALLOC] == "default"
@pytest.mark.skipif(sys.platform != "win32", reason="Relevant only for windows")
def test_pythonpath_with_one_source_test_mode_in_windows(dev_command, first_app):
"""Test get environment with one source, no tests sources, in test mode."""
env = dev_command.get_environment(first_app, test_mode=True)
assert env[PYTHONPATH] == f"{Path.cwd() / 'src'}"
assert env[PYTHONMALLOC] == "default"
@pytest.mark.skipif(sys.platform != "win32", reason="Relevant only for windows")
def test_pythonpath_with_two_sources_in_windows(dev_command, third_app):
"""Test get environment with two sources in windows."""
env = dev_command.get_environment(third_app, test_mode=False)
assert env[PYTHONPATH] == f"{Path.cwd() / 'src'};{Path.cwd()}"
assert env[PYTHONMALLOC] == "default"
@pytest.mark.skipif(sys.platform != "win32", reason="Relevant only for windows")
def test_pythonpath_with_two_sources_and_tests_in_windows(dev_command, third_app):
"""Test get environment with two sources and test sources in windows."""
third_app.test_sources = ["tests", "path/to/other"]
env = dev_command.get_environment(third_app, test_mode=True)
assert (
env[PYTHONPATH]
== f"{Path.cwd() / 'src'};{Path.cwd()};{Path.cwd() / 'path' / 'to'}"
)
assert env[PYTHONMALLOC] == "default"
@pytest.mark.skipif(sys.platform == "win32", reason="Relevant only for non-windows")
def test_pythonpath_with_one_source(dev_command, first_app):
"""Test get environment with one source."""
env = dev_command.get_environment(first_app, test_mode=False)
assert env[PYTHONPATH] == f"{Path.cwd() / 'src'}"
assert PYTHONMALLOC not in env
@pytest.mark.skipif(sys.platform == "win32", reason="Relevant only for non-windows")
def test_pythonpath_with_one_source_test_mode(dev_command, first_app):
"""Test get environment with one source, no tests sources, in test mode."""
env = dev_command.get_environment(first_app, test_mode=True)
assert env[PYTHONPATH] == f"{Path.cwd() / 'src'}"
assert PYTHONMALLOC not in env
@pytest.mark.skipif(sys.platform == "win32", reason="Relevant only for non-windows")
def test_pythonpath_with_two_sources_in_linux(dev_command, third_app):
"""Test get environment with two sources in linux."""
env = dev_command.get_environment(third_app, test_mode=False)
assert env[PYTHONPATH] == f"{Path.cwd() / 'src'}:{Path.cwd()}"
assert PYTHONMALLOC not in env
@pytest.mark.skipif(sys.platform == "win32", reason="Relevant only for non-windows")
def test_pythonpath_with_two_sources_and_tests_in_linux(dev_command, third_app):
"""Test get environment with two sources and test sources in linux."""
env = dev_command.get_environment(third_app, test_mode=True)
assert (
env[PYTHONPATH]
== f"{Path.cwd() / 'src'}:{Path.cwd()}:{Path.cwd() / 'path' / 'to'}"
)
assert PYTHONMALLOC not in env
def test_non_verbose_mode(dev_command, first_app):
"""Non-verbose mode doesn't include BRIEFCASE_DEBUG in the dev environment."""
dev_command.console.verbosity = LogLevel.INFO
env = dev_command.get_environment(first_app, test_mode=False)
assert "BRIEFCASE_DEBUG" not in env
def test_verbose_mode(dev_command, first_app):
"""Verbose mode adds BRIEFCASE_DEBUG to the dev environment."""
dev_command.console.verbosity = LogLevel.DEBUG
env = dev_command.get_environment(first_app, test_mode=False)
assert env["BRIEFCASE_DEBUG"] == "1"
|