MCPcopy
hub / github.com/CadQuery/cadquery / tearDown

Method tearDown

tests/test_cadquery.py:71–99  ·  view source on GitHub ↗

Update summary with data from this test. This is a really hacky way of doing it-- we get a startup event from module load, but there is no way in unittest to get a single shutdown event-- except for stuff in 2.7 and above So what we do here is to read the existing f

(self)

Source from the content-addressed store, hash-verified

69 summary_file: ClassVar[Path | None] = None
70
71 def tearDown(self):
72 """
73 Update summary with data from this test.
74 This is a really hacky way of doing it-- we get a startup event from module load,
75 but there is no way in unittest to get a single shutdown event-- except for stuff in 2.7 and above
76
77 So what we do here is to read the existing file, stick in more content, and leave it
78 """
79 svgFile = (self.tmpdir / self._testMethodName).with_suffix(".svg")
80
81 # all tests do not produce output
82 if svgFile.exists():
83 if self.summary_file is None:
84 type(self).summary_file = self.tmpdir / "testSummary.html"
85 writeStringToFile(SUMMARY_TEMPLATE, self.summary_file)
86 existingSummary = readFileAsString(self.summary_file)
87 svgText = readFileAsString(svgFile)
88 svgText = svgText.replace(
89 '<?xml version="1.0" encoding="UTF-8" standalone="no"?>', ""
90 )
91
92 # now write data into the file
93 # the content we are replacing it with also includes the marker, so it can be replaced again
94 existingSummary = existingSummary.replace(
95 "<!--TEST_CONTENT-->",
96 TEST_RESULT_TEMPLATE % (dict(svg=svgText, name=self._testMethodName)),
97 )
98
99 writeStringToFile(existingSummary, self.summary_file)
100
101 def saveModel(self, shape):
102 """

Callers

nothing calls this directly

Calls 3

writeStringToFileFunction · 0.90
readFileAsStringFunction · 0.90
replaceMethod · 0.45

Tested by

no test coverage detected