From 59768309571c8df1251e754db6e4b5771386fda8 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 13 Apr 2021 05:33:46 +0800 Subject: [PATCH] use different directories for different tests (#1864) --- tests/test_themes.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/test_themes.py b/tests/test_themes.py index 1624ae5d7..2b35e54a0 100644 --- a/tests/test_themes.py +++ b/tests/test_themes.py @@ -155,13 +155,13 @@ def test_theme_fallback_config(): app = create_ctfd() # Make an empty theme try: - os.mkdir(os.path.join(app.root_path, "themes", "foo")) + os.mkdir(os.path.join(app.root_path, "themes", "foo_fallback")) except OSError: pass # Without theme fallback, missing themes should disappear with app.app_context(): - set_config("ctf_theme", "foo") + set_config("ctf_theme", "foo_fallback") assert app.config["THEME_FALLBACK"] == False with app.test_client() as client: try: @@ -169,7 +169,7 @@ def test_theme_fallback_config(): except TemplateNotFound: pass try: - r = client.get("/themes/foo/static/js/pages/main.dev.js") + r = client.get("/themes/foo_fallback/static/js/pages/main.dev.js") except TemplateNotFound: pass destroy_ctfd(app) @@ -179,17 +179,17 @@ class ThemeFallbackConfig(TestingConfig): app = create_ctfd(config=ThemeFallbackConfig) with app.app_context(): - set_config("ctf_theme", "foo") + set_config("ctf_theme", "foo_fallback") assert app.config["THEME_FALLBACK"] == True with app.test_client() as client: r = client.get("/") assert r.status_code == 200 - r = client.get("/themes/foo/static/js/pages/main.dev.js") + r = client.get("/themes/foo_fallback/static/js/pages/main.dev.js") assert r.status_code == 200 destroy_ctfd(app) # Remove empty theme - os.rmdir(os.path.join(app.root_path, "themes", "foo")) + os.rmdir(os.path.join(app.root_path, "themes", "foo_fallback")) def test_theme_template_loading_by_prefix(): @@ -208,9 +208,10 @@ def test_theme_template_disallow_loading_admin_templates(): try: # Make an empty malicious theme filename = os.path.join( - app.root_path, "themes", "foo", "admin", "malicious.html" + app.root_path, "themes", "foo_disallow", "admin", "malicious.html" ) os.makedirs(os.path.dirname(filename), exist_ok=True) + set_config("ctf_theme", "foo_disallow") with open(filename, "w") as f: f.write("malicious") @@ -219,5 +220,6 @@ def test_theme_template_disallow_loading_admin_templates(): finally: # Remove empty theme shutil.rmtree( - os.path.join(app.root_path, "themes", "foo"), ignore_errors=True + os.path.join(app.root_path, "themes", "foo_disallow"), + ignore_errors=True, )