Exemplo n.º 1
0
def test_get_filename_with_passed_name():
    # arrange
    file = 'mcnp_examples/F2.out'
    # act
    filename = eddy.get_filename(file)
    # assert
    assert filename == file
Exemplo n.º 2
0
def test_get_filename_from_tkinter(mocker):
    # arrange
    mocker.patch("eddymc.eddy.askopenfilename",
                 return_value="mcnp_examples/F2.out")
    # act
    file = eddy.get_filename()
    # assert
    assert file == 'mcnp_examples/F2.out'
Exemplo n.º 3
0
def test_get_filename_from_tkinter(mocker, mock_tk):
    """This test is commented out because I can't get github workflows to
    ignore the Tk().withdraw() line, and it errors there because the server
    can't connect to a display.
    Solutions tried so far:
        setting the $DISPLAY variable in the workflow (sets the display, but tkinter can't connect)
        patching various combinations of Tk and withdraw
    """
    # arrange
    mocker.patch('eddymc.eddy.Tk', return_value=mock_tk())
    mocker.patch("eddymc.eddy.askopenfilename",
                 return_value="mcnp_examples/F2.out")
    # act
    file = eddy.get_filename()
    # assert
    assert file == 'mcnp_examples/F2.out'
Exemplo n.º 4
0
def test_get_filename_if_file_missing():
    # arrange
    name = 'mcnp_examples/nonexistent_file.out'
    # act, assert
    with pytest.raises(AssertionError):
        eddy.get_filename(name)