-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_load.py
57 lines (51 loc) · 1.96 KB
/
test_load.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import pytest
import loader
loader.INVENTORY_EXCEPTIONS = []
import os
from recipe import Recipe
from inventory import Item
from crafter import Crafter
@pytest.mark.usefixtures("tmpdir", "monkeypatch")
@pytest.mark.loading
def test_inv_load(tmpdir, monkeypatch):
monkeypatch.chdir(tmpdir)
with open(os.path.join(".", "inventory.item"), "w") as f:
f.write("name\n2xname2x3\n2xname2\n\n\nname3x1x1\n\n")
assert str(loader.get_inv().content) == str([Item("name", 1), Item("name2", 8), Item("name3x1", 1)])
@pytest.mark.usefixtures("tmpdir", "monkeypatch")
@pytest.mark.loading
def test_crafter_load(tmpdir, monkeypatch):
monkeypatch.chdir(tmpdir)
tmpdir.mkdir("crafter")
with open(os.path.join(".", "crafter", "name.crafter"), "w") as f:
f.write("")
assert str(loader.get_crafter()) == str([Crafter(os.path.join(os.getcwd(), "crafter", "name.crafter"), "")])
@pytest.mark.usefixtures("tmpdir", "monkeypatch", "capfd")
@pytest.mark.loading
def test_crafter_load_nothing(tmpdir, monkeypatch, capfd):
monkeypatch.chdir(tmpdir)
loader.get_crafter()
assert capfd.readouterr()[1] == "Aucune machine trouvée\n"
@pytest.mark.usefixtures("tmpdir", "monkeypatch")
@pytest.mark.loading
def test_recipe_load(tmpdir, monkeypatch):
monkeypatch.chdir(tmpdir)
tmpdir.mkdir("recipe")
with open(os.path.join(".", "recipe", "name.recipe"), "w") as f:
f.write("")
assert str(loader.get_recipes()) == str([Recipe(os.path.join(os.getcwd(), "recipe", "name.recipe"), "")])
@pytest.mark.usefixtures("tmpdir", "monkeypatch", "capfd")
@pytest.mark.loading
def test_recipe_load_nothing(tmpdir, monkeypatch, capfd):
monkeypatch.chdir(tmpdir)
with pytest.raises(SystemExit):
loader.get_recipes()
assert capfd.readouterr()[1] == "Aucune recette trouvée\n"
@pytest.mark.usefixtures("capfd")
@pytest.mark.loading
def test_loading(capfd):
import loading
loads = loading.Loading()
loads.valeur
del loads
assert True