File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,7 +75,6 @@ def run_app(user_args):
7575
7676 if user_args .batch_mode :
7777 for view_file in user_args .batch_mode :
78- print (view_file )
7978 mainWindow .saveBatchImage (view_file )
8079 mainWindow .close ()
8180 sys .exit ()
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ def _openmcReload(threads=None, model_path='.'):
3636 args = ["-c" ]
3737 if threads is not None :
3838 args += ["-s" , str (threads )]
39- args .append (model_path )
39+ args .append (str ( model_path ) )
4040 openmc .lib .init (args )
4141 openmc .lib .settings .verbosity = 1
4242
@@ -450,6 +450,14 @@ def updateWindowMenu(self):
450450 self .mainWindowAction .setChecked (self .isActiveWindow ())
451451
452452 def saveBatchImage (self , view_file ):
453+ """
454+ Loads a view in the GUI and generates an image
455+
456+ Parameters
457+ ----------
458+ view_file : str or pathlib.Path
459+ The path to a view file that is compatible with the loaded model.
460+ """
453461 # store the
454462 cv = self .model .currentView
455463 # load the view from file
Original file line number Diff line number Diff line change 11import filecmp
2+ import shutil
3+
24import pytest
5+
36from openmc_plotter .main_window import MainWindow , _openmcReload
47
58@pytest .fixture
@@ -12,12 +15,33 @@ def run_in_tmpdir(tmpdir):
1215
1316def test_window (tmpdir , qtbot ):
1417 orig = tmpdir .chdir ()
18+ mw = MainWindow (model_path = orig )
19+ _openmcReload (model_path = orig )
20+ mw .loadGui ()
21+
22+ try :
23+ mw .saveImage (tmpdir / 'test.png' )
24+ mw .close ()
25+ qtbot .addWidget (mw )
26+ finally :
27+ orig .chdir ()
1528
16- _openmcReload (model_path = str (orig ))
29+ filecmp .cmp (orig / 'ref.png' , tmpdir / 'test.png' )
30+
31+ def test_batch_image (tmpdir , qtbot ):
32+ orig = tmpdir .chdir ()
33+
34+ # move view file into tmpdir
35+ shutil .copy2 (orig / 'test.pltvw' , tmpdir )
36+
37+ _openmcReload (model_path = orig )
1738
1839 mw = MainWindow (model_path = orig )
1940 mw .loadGui ()
20- mw .saveImage (tmpdir / 'test.png' )
21- qtbot .addWidget (mw )
41+ try :
42+ mw .saveBatchImage ('test.pltvw' )
43+ qtbot .addWidget (mw )
44+ finally :
45+ orig .chdir ()
2246
23- filecmp .cmp (orig / 'ref.png' , tmpdir / 'test.png' )
47+ filecmp .cmp (orig / 'ref.png' , tmpdir / 'test.png' )
You can’t perform that action at this time.
0 commit comments