Skip to content

Commit

Permalink
refactor: move tests folder into src to fix font and path issues
Browse files Browse the repository at this point in the history
  • Loading branch information
meramsey committed Apr 16, 2022
1 parent 5671fbc commit 23c9d66
Show file tree
Hide file tree
Showing 29 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions config/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ python_files =
addopts =
--cov
--cov-config config/coverage.ini
--ignore=tests/test_app.py
--ignore=src/tests/test_app.py
testpaths =
tests
src/tests
4 changes: 2 additions & 2 deletions duties.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from git_changelog.build import Changelog, Version
from jinja2.sandbox import SandboxedEnvironment

PY_SRC_PATHS = (Path(_) for _ in ("src", "tests", "duties.py", "docs/macros.py"))
PY_SRC_PATHS = (Path(_) for _ in ("src", "duties.py", "docs/macros.py"))
PY_SRC_LIST = tuple(str(_) for _ in PY_SRC_PATHS)
PY_SRC = " ".join(PY_SRC_LIST)
TESTING = os.environ.get("TESTING", "0") in {"1", "true"}
Expand Down Expand Up @@ -351,7 +351,7 @@ def test(ctx, match: str = ""):
py_version = f"{sys.version_info.major}{sys.version_info.minor}"
os.environ["COVERAGE_FILE"] = f".coverage-{py_version}"
ctx.run(
["pytest", "-c", "config/pytest.ini", "-n", "auto", "-k", match, "tests"],
["pytest", "-c", "config/pytest.ini", "-n", "auto", "-k", match, "src/tests"],
title="Running tests",
pty=PTY,
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions tests/test_settings.py → src/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
)
from wizardwebssh.utils import UnicodeType

# base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


class TestSettings(unittest.TestCase):
def test_print_version(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py → src/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)


class TestUitls(unittest.TestCase):
class TestUtils(unittest.TestCase):
def test_to_str(self):
b = b"hello"
u = "hello"
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/wizardwebssh/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def print_version(flag):
)
define("version", type=bool, help="Show version information", callback=print_version)

# base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
base_dir = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# base_dir = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
# print(f'base_dir: {base_dir}')
font_dirs = ["wizardwebssh", "static", "css", "fonts"]
max_body_size = 1 * 1024 * 1024
Expand All @@ -80,12 +80,12 @@ def get_url(self, filename, dirs):

def get_app_settings(options):
settings = dict(
template_path=os.path.join(base_dir, "src", "wizardwebssh", "templates"),
static_path=os.path.join(base_dir, "src", "wizardwebssh", "static"),
template_path=os.path.join(base_dir, "wizardwebssh", "templates"),
static_path=os.path.join(base_dir, "wizardwebssh", "static"),
websocket_ping_interval=options.wpintvl,
debug=options.debug,
xsrf_cookies=options.xsrf,
font=Font(get_font_filename(options.font, os.path.join(base_dir, "src", *font_dirs)), font_dirs[1:]),
font=Font(get_font_filename(options.font, os.path.join(base_dir, *font_dirs)), font_dirs[1:]),
origin_policy=get_origin_setting(options),
)
# print(f'Settings: {settings}')
Expand Down

0 comments on commit 23c9d66

Please sign in to comment.