Skip to content

Commit 0017825

Browse files
committed
Fix tests
1 parent 84561e7 commit 0017825

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"python.testing.pytestArgs": [
3+
"tests"
4+
],
5+
"python.testing.unittestEnabled": false,
6+
"python.testing.pytestEnabled": true
7+
}

tests/files/test_contour.png

10 Bytes
Loading

tests/test_backend_ezdxf.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ def test_plot_with_data_outside_axes(self):
9999

100100
def test_plot_with_twin_axis_and_data_outside_axes(self):
101101
"""Test a simple line-plot command with data outside the axes."""
102+
# Use non-interactive backend to avoid Tkinter issues
103+
matplotlib.use("Agg")
104+
102105
fig, ax1 = plt.subplots()
103106
ax2 = ax1.twinx()
104107
ax1.plot(range(7), [1, 2, 3, 1e5, 5, 6, 7])
@@ -196,3 +199,37 @@ def test_plot_with_nans(self):
196199
assert (
197200
len(entities) == 1
198201
) # ideally we should have two lines (i.e. one broken line), but one interpolated line works as a hotfix
202+
203+
def test_plot_with_data_with_FM_layers(self):
204+
matplotlib.backend_bases.register_backend("dxf", backend_dxf.FigureCanvasDxfFM)
205+
"""Test a simple line-plot command with data outside the axes."""
206+
plt.plot(range(7), [1, 2, 3, 1e5, 5, 6, 7])
207+
plt.ylim(0, 7)
208+
plt.xlim(1, 6)
209+
210+
try:
211+
outfile = "tests/files/test_plot_with_data_outside_axes.dxf"
212+
plt.savefig(outfile, transparent=True)
213+
finally:
214+
plt.close()
215+
216+
# Load the DXF file and inspect its content
217+
doc = ezdxf.readfile(outfile)
218+
# Get all layers
219+
layers = doc.layers
220+
layer_names = [layer.dxf.name for layer in layers]
221+
222+
expected_layers = {
223+
"FM-Frame",
224+
"FM-Graph",
225+
"FM-Method",
226+
"FM-Text",
227+
"FM-Depth",
228+
"FM-Value",
229+
"FM-Location",
230+
}
231+
232+
for expected_layer in expected_layers:
233+
assert expected_layer in layer_names, (
234+
f"Layer {expected_layer} not found in DXF file."
235+
)

0 commit comments

Comments
 (0)