From 785dc2a3005645c1e2d757b938c57a511cfd3efd Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 10 Oct 2022 14:20:21 +0200 Subject: [PATCH] Test case for string formatting --- .../test/instance_string_formatting.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/ifcopenshell-python/test/instance_string_formatting.py diff --git a/src/ifcopenshell-python/test/instance_string_formatting.py b/src/ifcopenshell-python/test/instance_string_formatting.py new file mode 100644 index 0000000000..1ba8e28c4c --- /dev/null +++ b/src/ifcopenshell-python/test/instance_string_formatting.py @@ -0,0 +1,17 @@ +import pytest +import ifcopenshell + +def test_file_gc(): + f = ifcopenshell.file() + inst = f.createIfcWall(ifcopenshell.guid.new(), Name=chr(0x1F37A)) + # 0x1F37A should be encoded using X4 + assert '\\X4\\' in inst.to_string() + # to_string() should use upper case entity names + assert 'IFCWALL' in inst.to_string() + # __str__ uses camel case entity names + assert 'IfcWall' in str(inst) + # in fact, __str__ is equal to to_string(False) + assert str(inst) == inst.to_string(False) + +if __name__ == "__main__": + pytest.main(["-sx", __file__])