From 776861636dbd180b8ad0bcc9540d935afaf2b873 Mon Sep 17 00:00:00 2001 From: Sebastiaan Zeeff <33516116+SebastiaanZ@users.noreply.github.com> Date: Sun, 13 Oct 2019 11:36:06 +0200 Subject: Add subTest + move test_resource to resources subdir I've added a `self.subTest` to the `name` loop so we still test and get output for all names in the list if one of them fails the test. In addition, I've moved it to the `tests/bot/resources` subdirectory. --- tests/bot/resources/test_resources.py | 17 +++++++++++++++++ tests/test_resources.py | 16 ---------------- 2 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 tests/bot/resources/test_resources.py delete mode 100644 tests/test_resources.py (limited to 'tests') diff --git a/tests/bot/resources/test_resources.py b/tests/bot/resources/test_resources.py new file mode 100644 index 000000000..73937cfa6 --- /dev/null +++ b/tests/bot/resources/test_resources.py @@ -0,0 +1,17 @@ +import json +import unittest +from pathlib import Path + + +class ResourceValidationTests(unittest.TestCase): + """Validates resources used by the bot.""" + def test_stars_valid(self): + """The resource `bot/resources/stars.json` should contain a list of strings.""" + path = Path('bot', 'resources', 'stars.json') + content = path.read_text() + data = json.loads(content) + + self.assertIsInstance(data, list) + for name in data: + with self.subTest(name=name): + self.assertIsInstance(name, str) diff --git a/tests/test_resources.py b/tests/test_resources.py deleted file mode 100644 index 2fc36c697..000000000 --- a/tests/test_resources.py +++ /dev/null @@ -1,16 +0,0 @@ -import json -import unittest -from pathlib import Path - - -class ResourceValidationTests(unittest.TestCase): - """Validates resources used by the bot.""" - def test_stars_valid(self): - """The resource `bot/resources/stars.json` should contain a list of strings.""" - path = Path('bot', 'resources', 'stars.json') - content = path.read_text() - data = json.loads(content) - - self.assertIsInstance(data, list) - for name in data: - self.assertIsInstance(name, str) -- cgit v1.2.3