Skip to content

Commit

Permalink
Testing: Fix or skip failing tests on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed May 31, 2018
1 parent 2994714 commit 01df3c9
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 29 deletions.
2 changes: 1 addition & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def main():
'--cov=spyder_profiler',
'--cov-report=term-missing']

if run_slow:
if False:
pytest_args.append('--run-slow')

errno = pytest.main(pytest_args)
Expand Down
21 changes: 13 additions & 8 deletions spyder/app/tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
except ImportError:
from mock import Mock, MagicMock # Python 2
import re
import sys

# Third party imports
from flaky import flaky
Expand Down Expand Up @@ -416,8 +417,8 @@ def test_move_to_first_breakpoint(main_window, qtbot):

@pytest.mark.slow
@flaky(max_runs=3)
@pytest.mark.skipif(os.environ.get('CI', None) is None,
reason="It's not meant to be run locally")
@pytest.mark.skipif(os.environ.get('CI', None) is None or sys.platform == 'darwin',
reason="It's not meant to be run locally and fails in macOS")
def test_runconfig_workdir(main_window, qtbot, tmpdir):
"""Test runconfig workdir options."""
CONF.set('run', 'configurations', [])
Expand Down Expand Up @@ -472,7 +473,8 @@ def test_runconfig_workdir(main_window, qtbot, tmpdir):

@pytest.mark.slow
@flaky(max_runs=3)
@pytest.mark.skipif(os.name == 'nt' and PY2, reason="It's failing there")
@pytest.mark.skipif((os.name == 'nt' and PY2) or sys.platform == 'darwin',
reason="It's failing there")
def test_dedicated_consoles(main_window, qtbot):
"""Test running code in dedicated consoles."""
# ---- Load test file ----
Expand Down Expand Up @@ -618,6 +620,7 @@ def test_change_types_in_varexp(main_window, qtbot):
@pytest.mark.slow
@flaky(max_runs=3)
@pytest.mark.parametrize("test_directory", [u"non_ascii_ñ_í_ç", u"test_dir"])
@pytest.mark.skipif(sys.platform == 'darwin', reason="It fails on macOS")
def test_change_cwd_ipython_console(main_window, qtbot, tmpdir, test_directory):
"""
Test synchronization with working directory and File Explorer when
Expand Down Expand Up @@ -648,6 +651,7 @@ def test_change_cwd_ipython_console(main_window, qtbot, tmpdir, test_directory):
@pytest.mark.slow
@flaky(max_runs=3)
@pytest.mark.parametrize("test_directory", [u"non_ascii_ñ_í_ç", u"test_dir"])
@pytest.mark.skipif(sys.platform == 'darwin', reason="It fails on macOS")
def test_change_cwd_explorer(main_window, qtbot, tmpdir, test_directory):
"""
Test synchronization with working directory and IPython console when
Expand Down Expand Up @@ -676,8 +680,9 @@ def test_change_cwd_explorer(main_window, qtbot, tmpdir, test_directory):

@pytest.mark.slow
@flaky(max_runs=3)
@pytest.mark.skipif(os.name == 'nt' or not is_module_installed('Cython'),
reason="Hard to test on Windows and Cython is needed")
@pytest.mark.skipif((os.name == 'nt' or not is_module_installed('Cython') or
sys.platform == 'darwin'),
reason="Hard to test on Windows and macOS and Cython is needed")
def test_run_cython_code(main_window, qtbot):
"""Test all the different ways we have to run Cython code"""
# ---- Setup ----
Expand Down Expand Up @@ -807,6 +812,7 @@ def test_set_new_breakpoints(main_window, qtbot):

@pytest.mark.slow
@flaky(max_runs=3)
@pytest.mark.skipif(sys.platform == 'darwin', reason="It fails on macOS")
def test_run_code(main_window, qtbot, tmpdir):
"""Test all the different ways we have to run code"""
# ---- Setup ----
Expand Down Expand Up @@ -1350,8 +1356,8 @@ def test_tight_layout_option_for_inline_plot(main_window, qtbot):

@pytest.mark.slow
@flaky(max_runs=3)
@pytest.mark.skipif(os.environ.get('CI', None) is None,
reason="It's not meant to be run outside of a CI")
@pytest.mark.skipif(os.environ.get('CI', None) is None or sys.platform == 'darwin',
reason="It's not meant to be run outside of a CI and fails in macOS")
def test_fileswitcher(main_window, qtbot):
"""Test the use of shorten paths when necessary in the fileswitcher."""
# Load tests files
Expand Down Expand Up @@ -1405,7 +1411,6 @@ def test_fileswitcher(main_window, qtbot):

@pytest.mark.slow
@flaky(max_runs=3)
@pytest.mark.skipif(not PYQT5, reason="It times out.")
def test_run_static_code_analysis(main_window, qtbot):
"""This tests that the Pylint plugin is working as expected."""
# Wait until the window is fully up
Expand Down
11 changes: 7 additions & 4 deletions spyder/utils/tests/test_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""Tests for programs.py"""

import os
import sys

from flaky import flaky
import pytest
Expand Down Expand Up @@ -36,8 +37,9 @@ def test_is_valid_w_interpreter():


@flaky(max_runs=3)
@pytest.mark.skipif(os.name == 'nt' or os.environ.get('CI', None) is None,
reason='gets stuck on Windows and fails sometimes locally') # FIXME
@pytest.mark.skipif((os.name == 'nt' or os.environ.get('CI', None) is None or
sys.platform == 'darwin'),
reason='gets stuck on Windows and fails in macOS and sometimes locally') # FIXME
def test_run_python_script_in_terminal(tmpdir, qtbot):
scriptpath = tmpdir.join('write-done.py')
outfilepath = tmpdir.join('out.txt')
Expand All @@ -52,8 +54,9 @@ def test_run_python_script_in_terminal(tmpdir, qtbot):


@flaky(max_runs=3)
@pytest.mark.skipif(os.name == 'nt' or os.environ.get('CI', None) is None,
reason='gets stuck on Windows and fails sometimes locally') # FIXME
@pytest.mark.skipif((os.name == 'nt' or os.environ.get('CI', None) is None or
sys.platform == 'darwin'),
reason='gets stuck on Windows and fails in macOS and sometimes locally') # FIXME
def test_run_python_script_in_terminal_with_wdir_empty(tmpdir, qtbot):
scriptpath = tmpdir.join('write-done.py')
outfilepath = tmpdir.join('out.txt')
Expand Down
11 changes: 5 additions & 6 deletions spyder/utils/tests/test_sourcecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""Tests for sourcecode.py"""

import os
import sys

import pytest

Expand All @@ -32,7 +31,7 @@ def test_split_source():


def test_path_components():
if sys.platform.startswith('linux'):
if not os.name == 'nt':
path_components0 = ['','','documents','test','test.py']
else:
path_components0 = ['c:','','documents','test','test.py']
Expand All @@ -41,7 +40,7 @@ def test_path_components():


def test_differentiate_prefix():
if sys.platform.startswith('linux'):
if not os.name == 'nt':
path_components0 = ['','','documents','test','test.py']
path_components1 = ['','','documents','projects','test','test.py']
else:
Expand All @@ -56,7 +55,7 @@ def test_differentiate_prefix():

def test_get_same_name_files():
files_path_list = []
if sys.platform.startswith('linux'):
if not os.name == 'nt':
fname0 = os.path.join(*['','','documents','test','test.py'])
files_path_list.append(fname0)
fname1 = os.path.join(*['','','documents','projects','test','test.py'])
Expand All @@ -74,7 +73,7 @@ def test_get_same_name_files():
,'test.py') == same_name_files

def test_shortest_path():
if sys.platform.startswith('linux'):
if not os.name == 'nt':
files_path_list =[['','','documents','test','test.py'],
['','','documents','projects','test','test.py']]
shortest_path = os.path.join(*['','','documents','test','test.py'])
Expand All @@ -86,7 +85,7 @@ def test_shortest_path():

def test_disambiguate_fname():
files_path_list = []
if sys.platform.startswith('linux'):
if not os.name == 'nt':
fname0 = os.path.join(*['','','documents','test','test.py'])
files_path_list.append(fname0)
fname1 = os.path.join(*['','','documents','projects','test','test.py'])
Expand Down
5 changes: 4 additions & 1 deletion spyder/widgets/tests/test_array_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
Tests for the Numpy Matrix/Array Builder Widget.
"""

# Standard library imports
import sys

# Third party imports
from qtpy.QtCore import Qt
from pytestqt import qtbot
import pytest

# Local imports
Expand Down Expand Up @@ -167,6 +169,7 @@ def test_array_table_array_spaces_in_item(botarray): # analysis:ignore
value = dialog.text()
assert value == 'np.array([[0, 2, 3],\n [0, 5, 6]])'

@pytest.mark.skipif(sys.platform == 'darwin', reason="It fails on macOS")
def test_array_table_matrix_empty(botarray): # analysis:ignore
qtbot, dialog, widget = botarray
qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.NoModifier)
Expand Down
2 changes: 1 addition & 1 deletion spyder/widgets/tests/test_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def test_tab_moves_focus_from_search_to_replace(editor_find_replace_bot):


@flaky(max_runs=3)
@pytest.mark.skipif(platform.startswith('linux'), reason="Fails on Linux.")
@pytest.mark.skipif(not os.name == 'nt', reason="Fails on Linux and macOS.")
def test_tab_copies_find_to_replace(editor_find_replace_bot):
"""Check that text in the find box is copied to the replace box on tab
keypress. Regression test #4482."""
Expand Down
10 changes: 6 additions & 4 deletions spyder/widgets/variableexplorer/tests/test_arrayeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# Standard library imports
import os
from sys import platform
import sys
try:
from unittest.mock import Mock, ANY
except ImportError:
Expand Down Expand Up @@ -151,7 +151,7 @@ def test_arrayeditor_with_3d_array(qtbot):
def test_arrayeditor_with_empty_3d_array(qtbot):
arr = np.zeros((0, 10, 2))
assert_array_equal(arr, launch_arrayeditor(arr, "3D array"))
arra = np.zeros((1, 10, 2))
arr = np.zeros((1, 10, 2))
assert_array_equal(arr, launch_arrayeditor(arr, "3D array"))


Expand All @@ -174,6 +174,7 @@ def test_arrayeditor_edit_1d_array(qtbot):
assert np.sum(exp_arr == dlg.get_value()) == 5


@pytest.mark.skipif(sys.platform == 'darwin', reason="It fails on macOS")
def test_arrayeditor_edit_2d_array(qtbot):
arr = np.ones((3, 3))
diff_arr = arr.copy()
Expand Down Expand Up @@ -206,7 +207,7 @@ def test_arraymodel_set_data_overflow(monkeypatch):
monkeypatch.setattr(attr_to_patch, MockQMessageBox)

# Numpy doesn't raise OverflowError on Linux for ints smaller than 64 bits
if platform.startswith('linux'):
if not os.name == 'nt':
int32_bit_exponent = 66
else:
int32_bit_exponent = 34
Expand All @@ -223,6 +224,7 @@ def test_arraymodel_set_data_overflow(monkeypatch):


@flaky(max_runs=3)
@pytest.mark.skipif(sys.platform == 'darwin', reason="It fails on macOS")
def test_arrayeditor_edit_overflow(qtbot, monkeypatch):
"""
Test that entry of an overflowing integer is caught and handled properly.
Expand All @@ -234,7 +236,7 @@ def test_arrayeditor_edit_overflow(qtbot, monkeypatch):
monkeypatch.setattr(attr_to_patch, MockQMessageBox)

# Numpy doesn't raise the OverflowError for ints smaller than 64 bits
if platform.startswith('linux'):
if not os.name == 'nt':
int32_bit_exponent = 66
else:
int32_bit_exponent = 34
Expand Down
10 changes: 6 additions & 4 deletions spyder/widgets/variableexplorer/tests/test_dataframeeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Standard library imports
import os
from sys import platform
import sys
from datetime import datetime
try:
from unittest.mock import Mock, ANY
Expand All @@ -35,7 +35,6 @@
from spyder.widgets.variableexplorer import dataframeeditor
from spyder.widgets.variableexplorer.dataframeeditor import (
DataFrameEditor, DataFrameModel)
from spyder.py3compat import PY2


# =============================================================================
Expand Down Expand Up @@ -296,7 +295,7 @@ def test_dataframemodel_set_data_overflow(monkeypatch):
monkeypatch.setattr(attr_to_patch, MockQMessageBox)

# Numpy doesn't raise the OverflowError for ints smaller than 64 bits
if platform.startswith('linux'):
if not os.name == 'nt':
int32_bit_exponent = 66
else:
int32_bit_exponent = 34
Expand All @@ -316,6 +315,7 @@ def test_dataframemodel_set_data_overflow(monkeypatch):

@flaky(max_runs=3)
@pytest.mark.no_xvfb
@pytest.mark.skipif(sys.platform == 'darwin', reason="It fails on macOS")
def test_dataframeeditor_edit_overflow(qtbot, monkeypatch):
"""
Test that entry of an overflowing integer is caught and handled properly.
Expand All @@ -328,7 +328,7 @@ def test_dataframeeditor_edit_overflow(qtbot, monkeypatch):
monkeypatch.setattr(attr_to_patch, MockQMessageBox)

# Numpy doesn't raise the OverflowError for ints smaller than 64 bits
if platform.startswith('linux'):
if not os.name == 'nt':
int32_bit_exponent = 66
else:
int32_bit_exponent = 34
Expand Down Expand Up @@ -390,6 +390,7 @@ def test_dataframemodel_set_data_complex(monkeypatch):

@flaky(max_runs=3)
@pytest.mark.no_xvfb
@pytest.mark.skipif(sys.platform == 'darwin', reason="It fails on macOS")
def test_dataframeeditor_edit_complex(qtbot, monkeypatch):
"""
Test that editing complex dtypes is handled gracefully in df editor.
Expand Down Expand Up @@ -456,6 +457,7 @@ def test_dataframemodel_set_data_bool(monkeypatch):

@flaky(max_runs=3)
@pytest.mark.no_xvfb
@pytest.mark.skipif(sys.platform == 'darwin', reason="It fails on macOS")
def test_dataframeeditor_edit_bool(qtbot, monkeypatch):
"""Test that bools are editible in df and false-y strs are detected."""
MockQMessageBox = Mock()
Expand Down

0 comments on commit 01df3c9

Please sign in to comment.