| blc2 - Python library and frontend for running theatrical lighting and SFX. Written for the English 2041F fall 2019 theatre production of "The Cenci".
git clone https://benconnors.ca/git-repos/blc2 |
conftest.py (1223B) - raw
1 import datetime as dt 2 import xml.etree.ElementTree as et 3 4 import pytest 5 6 from blc2.workspace import Workspace 7 from blc2.topology import Fixture 8 9 @pytest.fixture 10 def ws(): 11 """Return a workspace.""" 12 return Workspace("", "" ,"", dt.datetime.now()) 13 14 @pytest.fixture 15 def aws(): 16 """Return a more advanced workspace with 4 channels on 1 fixture.""" 17 w = Workspace("", "", "", dt.datetime.now()) 18 Fixture(w, id_=0, channel_count=4) 19 return w 20 21 def elements_equal(e1, e2): 22 """Determine if two XML elements are equal.""" 23 if e1.tag != e2.tag: 24 return False 25 if ("" if e1.text is None else e1.text).strip("\r\n\t ") != ("" if e2.text is None else e2.text).strip("\r\n\t "): 26 return False 27 if ("" if e1.tail is None else e1.tail).strip("\r\n\t ") != ("" if e2.tail is None else e2.tail).strip("\r\n\t "): 28 return False 29 if e1.attrib != e2.attrib: 30 return False 31 if len(e1) != len(e2): 32 return False 33 return all(elements_equal(c1, c2) for c1, c2 in zip(e1, e2)) 34 35 @pytest.fixture 36 def test_xml_eq(): 37 """Use for testing serialization functions.""" 38 def inner(e: et.Element, s: str): 39 return elements_equal(e, et.fromstring(s)) 40 return inner