<commit_before>#!/usr/bin/env python
from peacock.utils import Testing
from PyQt5 import QtWidgets
import os

class TestChangeInputFile(Testing.PeacockAppImageTestCase):
    """
    Tests that if the input file changes the VTKWindow is reset.
    """
    qapp = QtWidgets.QApplication([])

    def testInputReset(self):
        """
        Test that changing the input file resets the VTK window correctly.
        """

        # The tabs to switch between
        start_dir = os.getcwd()
        input_ = self._app.main_widget.tab_plugin.InputFileEditorWithMesh
        exodus = self._app.main_widget.tab_plugin.ExodusViewer
        execute = self._app.main_widget.tab_plugin.ExecuteTabPlugin

        # The variable plugin
        var_plugin = exodus.currentWidget().VariablePlugin
        blk_selector = exodus.currentWidget().BlockPlugin.BlockSelector.ListWidget

        # Run and check output
        self.selectTab(execute)
        self.execute()
        self.selectTab(exodus)

        self.assertEqual([var_plugin.VariableList.itemText(i) for i in range(var_plugin.VariableList.count())], ['u'])
        self.assertEqual([blk_selector.item(i).text() for i in range(blk_selector.count())], ['0'])

        # Change the colormap (to test that the colormap is maintained)
        idx = [var_plugin.ColorMapList.itemText(i) for i in range(var_plugin.ColorMapList.count())].index('magma')
        var_plugin.ColorMapList.setCurrentIndex(idx)
        var_plugin.ColorMapList.currentIndexChanged.emit(idx)

        # Change the input
        self.selectTab(input_)
        input_.setInputFile("../../common/simple_diffusion2.i")

        # Run and check output
        self.selectTab(execute)
        execute.ExecuteOptionsPlugin.setWorkingDir(start_dir)
        self.execute()
        self.selectTab(exodus)
        self.assertEqual([var_plugin.VariableList.itemText(i) for i in range(var_plugin.VariableList.count())], ['aux', 'not_u', 'u'])
        self.assertEqual([blk_selector.item(i).text() for i in range(blk_selector.count())], ['0', '1980'])

        # Check colormap
        self.assertEqual(self._window._result.getOption('cmap'), 'magma')<commit_msg>Try to avoid race conditions with exodus files.<commit_after>#!/usr/bin/env python
from peacock.utils import Testing
from PyQt5 import QtWidgets
import os

class TestChangeInputFile(Testing.PeacockAppImageTestCase):
    """
    Tests that if the input file changes the VTKWindow is reset.
    """
    qapp = QtWidgets.QApplication([])

    def testInputReset(self):
        """
        Test that changing the input file resets the VTK window correctly.
        """

        # The tabs to switch between
        start_dir = os.getcwd()
        input_ = self._app.main_widget.tab_plugin.InputFileEditorWithMesh
        exodus = self._app.main_widget.tab_plugin.ExodusViewer
        execute = self._app.main_widget.tab_plugin.ExecuteTabPlugin

        # The variable plugin
        var_plugin = exodus.currentWidget().VariablePlugin
        blk_selector = exodus.currentWidget().BlockPlugin.BlockSelector.ListWidget

        # Run and check output
        self.selectTab(execute)
        execute.ExecuteOptionsPlugin.setWorkingDir(start_dir)
        self.execute()
        self.selectTab(exodus)

        self.assertEqual([var_plugin.VariableList.itemText(i) for i in range(var_plugin.VariableList.count())], ['u'])
        self.assertEqual([blk_selector.item(i).text() for i in range(blk_selector.count())], ['0'])

        # Change the colormap (to test that the colormap is maintained)
        idx = [var_plugin.ColorMapList.itemText(i) for i in range(var_plugin.ColorMapList.count())].index('magma')
        var_plugin.ColorMapList.setCurrentIndex(idx)
        var_plugin.ColorMapList.currentIndexChanged.emit(idx)

        # Change the input
        self.selectTab(input_)
        input_.setInputFile("../../common/simple_diffusion2.i")

        # Run and check output
        self.selectTab(execute)
        execute.ExecuteOptionsPlugin.setWorkingDir(start_dir)
        self.execute()
        self.selectTab(exodus)
        self.assertEqual([var_plugin.VariableList.itemText(i) for i in range(var_plugin.VariableList.count())], ['aux', 'not_u', 'u'])
        self.assertEqual([blk_selector.item(i).text() for i in range(blk_selector.count())], ['0', '1980'])

        # Check colormap
        self.assertEqual(self._window._result.getOption('cmap'), 'magma')
{'fraction_non_alphanumeric': 0.11183913239945775, 'fraction_numerical': 0.0036150022593764122, 'mean_word_length': 3.1922348484848486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1568958', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1268, 'n_words': 265}