-
Notifications
You must be signed in to change notification settings - Fork 11
/
test_history.py
55 lines (38 loc) · 1.24 KB
/
test_history.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
import os
import pytest
from uranium.history import History
from uranium.exceptions import HistoryException
def test_creates_file(history):
assert not os.path.exists(history.path)
history.save()
assert os.path.exists(history.path)
def test_save_load(history):
history["foo"] = "bar"
history.save()
new_history = History(history.path)
new_history.load()
assert history["foo"] == "bar"
def test_no_fail_on_load_no_file(history):
history.load()
def test_not_able_to_serialize(history):
import re
history["unserializable"] = re.compile("foo")
with pytest.raises(HistoryException):
history.save()
def test_not_able_to_serialize_subattribute(history):
import re
history["unserializable"] = [re.compile("foo")]
with pytest.raises(HistoryException):
history.save()
history["unserializable"] = {"foo": re.compile("foo")}
with pytest.raises(HistoryException):
history.save()
def test_history_with_build(tmpdir, build):
@build.task
def main(build):
was_set = build.history.get("set", False)
build.history["set"] = True
return was_set
assert build.run_task("main") is 0
build.tasks.clear_cache()
assert build.run_task("main") is 1