From 60960aa0953cefe97ac6221248666f40d1be10e0 Mon Sep 17 00:00:00 2001 From: sezanzeb Date: Sat, 15 Jan 2022 15:03:21 +0100 Subject: [PATCH] Made tests in PyCharm work --- .run/All Tests.run.xml | 16 ++++++++++++++++ tests/__init__.py | 2 ++ tests/test.py | 13 +++++++------ 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 .run/All Tests.run.xml diff --git a/.run/All Tests.run.xml b/.run/All Tests.run.xml new file mode 100644 index 00000000..57544171 --- /dev/null +++ b/.run/All Tests.run.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py index e69de29b..6ab9b83b 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1,2 @@ +# make sure patches are loaded +import tests.test diff --git a/tests/test.py b/tests/test.py index 1b8764f9..d3d58846 100644 --- a/tests/test.py +++ b/tests/test.py @@ -23,6 +23,9 @@ import os import sys +# the working directory should be the project root +assert not os.getcwd().endswith("tests") + # make sure the "tests" module visible sys.path.append(os.getcwd()) if __name__ == "__main__": @@ -51,10 +54,7 @@ gi.require_version("Gtk", "3.0") gi.require_version("GLib", "2.0") gi.require_version("GtkSource", "4") -from xmodmap import xmodmap - -assert not os.getcwd().endswith("tests") - +from tests.xmodmap import xmodmap os.environ["UNITTEST"] = "1" @@ -660,9 +660,10 @@ def spy(obj, name): return patch.object(obj, name, wraps=obj.__getattribute__(name)) -def main(): - cleanup() +cleanup() + +def main(): modules = sys.argv[1:] # discoverer is really convenient, but it can't find a specific test # in all of the available tests like unittest.main() does...,