From 7356e651e7ed46f49b358acb6f391b608eee92b9 Mon Sep 17 00:00:00 2001 From: jelleas Date: Fri, 14 Jun 2019 15:42:50 -0400 Subject: [PATCH] default in lab50 tests --- tests/lib50_tests.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/lib50_tests.py b/tests/lib50_tests.py index 0f24409..93d69c4 100644 --- a/tests/lib50_tests.py +++ b/tests/lib50_tests.py @@ -431,10 +431,11 @@ def test_non_file_require(self): included, excluded = lib50.files(config.get("files")) def test_lab50_tags(self): - # Three dummy files + # Four dummy files open("foo.py", "w").close() open("bar.py", "w").close() open("baz.py", "w").close() + open("qux.py", "w").close() # Dummy config file (.cs50.yml) content = \ @@ -442,31 +443,32 @@ def test_lab50_tags(self): " files:\n" \ " - !open \"foo.py\"\n" \ " - !include \"bar.py\"\n" \ - " - !exclude \"baz.py\"\n" + " - !exclude \"baz.py\"\n" \ + " - \"qux.py\"\n" # Create a config Loader for a tool called lab50 loader = lib50.config.Loader("lab50") # Scope the files section of lab50 with the tags: open, include and exclude - loader.scope("files", "open", "include", "exclude") + loader.scope("files", "open", "include", "exclude", default="include") # Load the config config = loader.load(content) # Figure out which files have an open tag - opened_files = [tagged_value.value for tagged_value in config.get("files") if tagged_value.tag == "open"] + opened_files = [tagged_value.value for tagged_value in config["files"] if tagged_value.tag == "open"] # Have lib50.files figure out which files should be included and excluded # Simultaneously ensure all open files exist - included, excluded = lib50.files(config.get("files"), require_tags=["open"]) + included, excluded = lib50.files(config["files"], require_tags=["open"]) # Make sure that files tagged with open are also included opened_files = [file for file in opened_files if file in included] # Assert - self.assertEqual(included, {"foo.py", "bar.py"}) + self.assertEqual(included, {"foo.py", "bar.py", "qux.py"}) self.assertEqual(excluded, {"baz.py"}) - self.assertEqual(opened_files, ["foo.py"]) + self.assertEqual(set(opened_files), {"foo.py"}) class TestLocal(unittest.TestCase):