mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Make test runnable from command line.
`pytest tests` works now. I can't explain why `pytest` alone does not,
but it could have something to do with us not being a real Python
package.
With just `pytest` I get:
E ModuleNotFoundError: No module named 'tests.test_factions'
But `python -c "import tests.test_factions"` works fine.
This commit is contained in:
parent
f365487fd6
commit
258c34e61d
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
@ -1,4 +1,5 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
from dcs.helicopters import UH_1H, AH_64A
|
||||
@ -11,13 +12,17 @@ from dcs.vehicles import Armor, Unarmed, Infantry, Artillery
|
||||
from game.factions.faction import Faction
|
||||
|
||||
|
||||
THIS_DIR = Path(__file__).parent
|
||||
RESOURCES_DIR = THIS_DIR / "resources"
|
||||
|
||||
|
||||
class TestFactionLoader(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_load_valid_faction(self):
|
||||
with open("./resources/valid_faction.json", 'r') as data:
|
||||
with (RESOURCES_DIR / "valid_faction.json").open('r') as data:
|
||||
faction = Faction.from_json(json.load(data))
|
||||
|
||||
self.assertEqual(faction.country, "USA")
|
||||
@ -87,7 +92,7 @@ class TestFactionLoader(unittest.TestCase):
|
||||
|
||||
def test_load_valid_faction_with_invalid_country(self):
|
||||
|
||||
with open("./resources/invalid_faction_country.json", 'r') as data:
|
||||
with (RESOURCES_DIR / "invalid_faction_country.json").open("r") as data:
|
||||
try:
|
||||
Faction.from_json(json.load(data))
|
||||
self.fail("Should have thrown assertion error")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user