Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Move testing infrastructure to use pytest #315

Merged
merged 5 commits into from
Nov 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ __pycache__
\#*#
.#*
.coverage
.pytest_cache
24 changes: 11 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@ language: python
sudo: false

env:
global:
- CONDA_DEPENDENCIES='pyqt traitlets ipython_genutils jupyter_core jupyter_client pygments ipykernel nose'
- PIP_DEPENDENCIES='coveralls'
global:
- CONDA_DEPENDENCIES='pyqt traitlets ipython_genutils jupyter_core jupyter_client pygments ipykernel pytest pytest-cov mock'
- PIP_DEPENDENCIES='coveralls pytest-xvfb'

matrix:
include:
- python: "3.6"
- python: "3.5"
- python: "3.4"
- python: "2.7"
env: PIP_DEPENDENCIES="coveralls mock"
include:
- python: "3.6"
- python: "3.5"
- python: "2.7"

install:
- git clone --depth 1 git://github.com/astropy/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh
- git clone --depth 1 git://github.com/astropy/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh

script:
- nosetests --with-coverage --cover-package qtconsole qtconsole
- pytest -x -vv --cov=qtconsole qtconsole

after_success:
- coveralls
- coveralls
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ python setup.py develop
Finally, to run the tests:

```
nosetests
pytest
```
2 changes: 1 addition & 1 deletion qtconsole/console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ def _get_word_end_cursor(self, position):
def _indent(self, dedent=True):
""" Indent/Dedent current line or current text selection.
"""
num_newlines = self._get_cursor().selectedText().count("\u2029")
num_newlines = self._get_cursor().selectedText().count(u"\u2029")
save_cur = self._get_cursor()
cur = self._get_cursor()

Expand Down
6 changes: 6 additions & 0 deletions qtconsole/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

import os
import sys

no_display = (sys.platform not in ('darwin', 'win32') and
os.environ.get('DISPLAY', '') == '')
27 changes: 14 additions & 13 deletions qtconsole/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@
# Distributed under the terms of the Modified BSD License.

import os
import shutil
import sys
import tempfile
from subprocess import check_output

from jupyter_core import paths
import pytest
from traitlets.tests.utils import check_help_all_output
from ipython_genutils.testing.decorators import skip_if_no_x11

@skip_if_no_x11
from . import no_display


@pytest.mark.skipif(no_display, reason="Doesn't work without a display")
def test_help_output():
"""jupyter qtconsole --help-all works"""
check_help_all_output('qtconsole')

@skip_if_no_x11

@pytest.mark.skipif(no_display, reason="Doesn't work without a display")
@pytest.mark.skipif(os.environ.get('CI', None) is None,
reason="Doesn't work outside of our CIs")
def test_generate_config():
"""jupyter qtconsole --generate-config"""
td = tempfile.mkdtemp()
try:
check_output([sys.executable, '-m', 'qtconsole', '--generate-config'],
env={'JUPYTER_CONFIG_DIR': td},
)
assert os.path.isfile(os.path.join(td, 'jupyter_qtconsole_config.py'))
finally:
shutil.rmtree(td)
config_dir = paths.jupyter_config_dir()
check_output([sys.executable, '-m', 'qtconsole', '--generate-config'])
assert os.path.isfile(os.path.join(config_dir,
'jupyter_qtconsole_config.py'))
9 changes: 5 additions & 4 deletions qtconsole/tests/test_completion_widget.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# -*- coding: utf-8 -*-
import unittest

import pytest

from qtconsole.qt import QtCore, QtGui
from qtconsole.qt_loaders import load_qtest

from qtconsole.console_widget import ConsoleWidget
from qtconsole.completion_widget import CompletionWidget
import ipython_genutils.testing.decorators as dec
from . import no_display

QTest = load_qtest()

setup = dec.skip_file_no_x11(__name__)
QTest = load_qtest()


@pytest.mark.skipif(no_display, reason="Doesn't work without a display")
class TestCompletionWidget(unittest.TestCase):

@classmethod
Expand Down
9 changes: 6 additions & 3 deletions qtconsole/tests/test_console_widget.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import unittest

import pytest

from qtconsole.qt import QtCore, QtGui
from qtconsole.qt_loaders import load_qtest

from qtconsole.console_widget import ConsoleWidget
import ipython_genutils.testing.decorators as dec
from . import no_display


setup = dec.skip_file_no_x11(__name__)
QTest = load_qtest()


@pytest.mark.skipif(no_display, reason="Doesn't work without a display")
class TestConsoleWidget(unittest.TestCase):

@classmethod
Expand Down
7 changes: 5 additions & 2 deletions qtconsole/tests/test_frontend_widget.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import unittest

import pytest

from qtconsole.qt import QtGui
from qtconsole.qt_loaders import load_qtest
from qtconsole.frontend_widget import FrontendWidget
import ipython_genutils.testing.decorators as dec
from . import no_display


setup = dec.skip_file_no_x11(__name__)
QTest = load_qtest()


@pytest.mark.skipif(no_display, reason="Doesn't work without a display")
class TestFrontendWidget(unittest.TestCase):

@classmethod
Expand Down
7 changes: 5 additions & 2 deletions qtconsole/tests/test_jupyter_widget.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import unittest

import pytest

from qtconsole.qt import QtGui
from qtconsole.qt_loaders import load_qtest
from qtconsole.client import QtKernelClient
from qtconsole.jupyter_widget import JupyterWidget
import ipython_genutils.testing.decorators as dec
from . import no_display


setup = dec.skip_file_no_x11(__name__)
QTest = load_qtest()


@pytest.mark.skipif(no_display, reason="Doesn't work without a display")
class TestJupyterWidget(unittest.TestCase):

@classmethod
Expand Down
11 changes: 6 additions & 5 deletions qtconsole/tests/test_kill_ring.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import unittest

from qtconsole.qt import QtGui
import pytest

from qtconsole.qt import QtGui
from qtconsole.kill_ring import KillRing, QtKillRing
import ipython_genutils.testing.decorators as dec
from . import no_display

setup = dec.skip_file_no_x11(__name__)

@pytest.mark.skipif(no_display, reason="Doesn't work without a display")
class TestKillRing(unittest.TestCase):

@classmethod
Expand Down Expand Up @@ -80,5 +81,5 @@ def test_qt_cursor(self):


if __name__ == '__main__':
import nose
nose.main()
import pytest
pytest.main()
1 change: 1 addition & 0 deletions qtconsole/tests/test_styles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

from qtconsole.styles import dark_color, dark_style


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
]

extras_require = setuptools_args['extras_require'] = {
'test': ['nose'],
'test': ['pytest'],
'test:python_version=="2.7"': ['mock'],
'doc': 'Sphinx>=1.3',
}
Expand Down