Skip to content

Commit

Permalink
1 more step to remove nose (#7952)
Browse files Browse the repository at this point in the history
* Tagged with pytest

* tox working

* py2 pytests version

* organized imports
  • Loading branch information
lasote authored Oct 28, 2020
1 parent 847ec0a commit 4eb8f02
Show file tree
Hide file tree
Showing 52 changed files with 232 additions and 115 deletions.
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Using tox
$ python -m tox
It will install the needed requirements and launch `nose` skipping some heavy and slow tests.
It will install the needed requirements and launch `pytest` skipping some heavy and slow tests.
If you want to run the full test suite:

.. code-block:: bash
Expand Down Expand Up @@ -180,15 +180,15 @@ You can run the actual tests like this:

.. code-block:: bash
$ python -m nose .
$ python -m pytest .
There are a couple of test attributes defined, as ``slow`` that you can use
to filter the tests, and do not execute them:

.. code-block:: bash
$ python -m nose . -a !slow
$ python -m pytest . -m "not slow"
A few minutes later it should print ``OK``:

Expand All @@ -204,16 +204,16 @@ To run specific tests, you can specify the test name too, something like:

.. code-block:: bash
$ python -m nose conans.test.command.config_install_test:ConfigInstallTest.install_file_test --nocapture
$ python -m pytest conans/test/unittests/client/cmd/export_test.py::ExportTest::test_export_warning -s
The ``--nocapture`` argument can be useful to see some output that otherwise is captured by nosetests.
The ``-s`` argument can be useful to see some output that otherwise is captured by pytest.

Also, you can run tests against an instance of Artifactory. Those tests should add the attribute
``artifactory_ready``.

.. code-block:: bash
$ python -m nose . -A artifactory_ready
$ python -m pytest . -m artifactory_ready
Some environment variables have to be defined to run them. For example, for an
Artifactory instance that is running on the localhost with default user and password configured, the
Expand Down
2 changes: 2 additions & 0 deletions conans/requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
nose>=1.3.7, <1.4.0
pytest>=6.1.1, <7.0.0; python_version > '3.0'
pytest>=4.6.11; python_version < '3.0'
parameterized>=0.6.3
mock>=1.3.0, <1.4.0
WebTest>=2.0.18, <2.1.0
Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/build_helpers/cmake_configs_test.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import os
import unittest

import pytest
from nose.plugins.attrib import attr

from conans.test.utils.multi_config import multi_config_files
from conans.test.utils.tools import TestClient


@attr("slow")
@pytest.mark.slow
class CMakeConfigsTest(unittest.TestCase):

def test_test_package_configs(self):
Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/build_helpers/cmake_flags_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import unittest
from textwrap import dedent

import pytest
from nose.plugins.attrib import attr
from parameterized.parameterized import parameterized

Expand Down Expand Up @@ -61,6 +62,7 @@ def package_info(self):


@attr("slow")
@pytest.mark.slow
class CMakeFlagsTest(unittest.TestCase):

def _get_line(self, text, begin):
Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/build_helpers/cmake_targets_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import platform
import unittest

import pytest
from nose.plugins.attrib import attr

from conans.test.utils.tools import TestClient
Expand Down Expand Up @@ -47,6 +48,7 @@ def package(self):


@attr("slow")
@pytest.mark.slow
class CMakeTargetsTest(unittest.TestCase):
def test_transitive_flags(self):
client = TestClient()
Expand Down
6 changes: 5 additions & 1 deletion conans/test/functional/build_helpers/msbuild_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
import textwrap
import unittest

import pytest
import six
from nose.plugins.attrib import attr
from parameterized import parameterized

from conans.client.tools.files import replace_in_file
from conans.model.ref import PackageReference
from conans.paths import CONANFILE
from conans.test.utils.deprecation import catch_deprecation_warning
from conans.test.utils.tools import TestClient
from conans.test.utils.visual_project_files import get_vs_project_files
from conans.test.utils.deprecation import catch_deprecation_warning
from conans.util.files import load


class MSBuildTest(unittest.TestCase):

@attr('slow')
@pytest.mark.slow
@unittest.skipUnless(platform.system() == "Windows" and six.PY3, "Requires MSBuild")
def test_build_vs_project(self):
conan_build_vs = """
Expand Down Expand Up @@ -101,6 +103,7 @@ def package(self):
self.assertTrue(os.path.exists(os.path.join(build_folder, "mp.props")))

@attr('slow')
@pytest.mark.slow
@unittest.skipUnless(platform.system() == "Windows", "Requires MSBuild")
def test_user_properties_file(self):
conan_build_vs = textwrap.dedent("""
Expand Down Expand Up @@ -153,6 +156,7 @@ def package(self):
self.assertIn("<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>", content)

@attr('slow')
@pytest.mark.slow
@unittest.skipUnless(platform.system() == "Windows", "Requires MSBuild")
def test_user_properties_multifile(self):
conan_build_vs = textwrap.dedent("""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest

import pytest
from nose.plugins.attrib import attr

from conans.test.utils.cpp_test_files import cpp_hello_conan_files
Expand Down Expand Up @@ -58,6 +59,7 @@ def build(self):


@attr("slow")
@pytest.mark.slow
class BuildRequiresTest(unittest.TestCase):

def test_test_framework(self):
Expand Down
10 changes: 5 additions & 5 deletions conans/test/functional/command/info/info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,14 @@ class MyTest(ConanFile):

client.run("info ./subfolder --json=output.json")
output = json.loads(client.load('output.json'))[0]
self.assertEquals(output['reference'], 'conanfile.py (Pkg/0.2)')
self.assertEqual(output['reference'], 'conanfile.py (Pkg/0.2)')
self.assertListEqual(output['license'], ['MIT', ])
self.assertEquals(output['author'], 'John Doe')
self.assertEqual(output['author'], 'John Doe')
self.assertListEqual(output['topics'], ['foo', 'bar', 'qux'])
self.assertEquals(output['url'], 'https://foo.bar.baz')
self.assertEquals(output['homepage'], 'https://foo.bar.site')
self.assertEqual(output['url'], 'https://foo.bar.baz')
self.assertEqual(output['homepage'], 'https://foo.bar.site')
self.assertListEqual(output['provides'], ['libjpeg', 'libjpg'])
self.assertEquals(output['deprecated'], 'other-pkg')
self.assertEqual(output['deprecated'], 'other-pkg')

def test_topics_graph(self):

Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/command/test_command_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import time
import unittest

import pytest
from nose.plugins.attrib import attr

from conans.model.ref import PackageReference
Expand All @@ -12,6 +13,7 @@


@attr("slow")
@pytest.mark.slow
class ConanTestTest(unittest.TestCase):

def test_partial_reference(self):
Expand Down
5 changes: 3 additions & 2 deletions conans/test/functional/command/upload/upload_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import itertools
import os
import platform
import stat
import unittest
from collections import OrderedDict

import itertools
import pytest
import requests
from mock import patch
from nose.plugins.attrib import attr
Expand All @@ -19,7 +20,6 @@
from conans.test.utils.tools import NO_SETTINGS_PACKAGE_ID, TestClient, TestServer, \
TurboTestClient, GenConanfile, TestRequester, TestingResponse
from conans.util.env_reader import get_env

from conans.util.files import gzopen_without_timestamps, is_dirty, save, set_dirty

conanfile = """from conans import ConanFile
Expand Down Expand Up @@ -67,6 +67,7 @@ def test_upload_dirty(self):
client.run("upload * --all --confirm")

@attr("artifactory_ready")
@pytest.mark.artifactory_ready
def test_upload_force(self):
ref = ConanFileReference.loads("Hello/0.1@conan/testing")
client = TurboTestClient(servers={"default": TestServer()})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import unittest
from collections import OrderedDict

import pytest
import six
from nose.plugins.attrib import attr

Expand Down Expand Up @@ -126,6 +127,7 @@ def test_cross_remotes(self):
self.assertEqual(0, len(module["dependencies"]))

@attr('ide_fail')
@pytest.mark.ide_fail
def test_trace_command(self):
from conans.build_info.command import run
trace_file = os.path.join(temp_folder(), "conan_trace.log")
Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/conanfile/conan_data_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import textwrap
import unittest

import pytest
import yaml
from bottle import static_file
from nose.plugins.attrib import attr
Expand Down Expand Up @@ -87,6 +88,7 @@ def package_info(self):
self.assertIn("My URL:", client.out)

@attr("slow")
@pytest.mark.slow
@attr('local_bottle')
def test_conan_data_as_source(self):
tgz_path = tgz_with_contents({"foo.txt": "foo"})
Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/environment/apply_environment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import platform
import unittest

import pytest
from nose.plugins.attrib import attr

from conans.client import tools
Expand All @@ -17,6 +18,7 @@
class ConanEnvTest(unittest.TestCase):

@attr('slow')
@pytest.mark.slow
def test_shared_in_current_directory(self):
"""
- There is a package building a shared library
Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/generators/cmake_components_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import textwrap
import unittest

import pytest
from nose.plugins.attrib import attr

from conans.model.ref import ConanFileReference
Expand All @@ -9,6 +10,7 @@


@attr('slow')
@pytest.mark.slow
class CMakeGeneratorsWithComponentsTest(unittest.TestCase):

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import textwrap
import unittest

import pytest
from nose.plugins.attrib import attr
from parameterized import parameterized

Expand All @@ -12,6 +13,7 @@


@attr('slow')
@pytest.mark.slow
class CMakeFindPathMultiGeneratorTest(unittest.TestCase):

def test_native_export_multi(self):
Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/generators/cmake_find_package_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import textwrap
import unittest

import pytest
import six
from nose.plugins.attrib import attr

Expand All @@ -14,6 +15,7 @@


@attr('slow')
@pytest.mark.slow
class CMakeFindPathGeneratorTest(unittest.TestCase):

def test_cmake_find_package_system_libs(self):
Expand Down
5 changes: 4 additions & 1 deletion conans/test/functional/generators/cmake_multi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import textwrap
import unittest

import pytest
from nose.plugins.attrib import attr

from conans.client.tools import load, remove_from_path
from conans.client.tools import remove_from_path
from conans.test.utils.multi_config import multi_config_files
from conans.test.utils.tools import TestClient

Expand Down Expand Up @@ -132,9 +133,11 @@ def package_files(name, deps=None):


@attr("slow")
@pytest.mark.slow
class CMakeMultiTest(unittest.TestCase):

@attr("mingw")
@pytest.mark.tool_mingw
def test_cmake_multi_find(self):
if platform.system() not in ["Windows", "Linux"]:
return
Expand Down
3 changes: 3 additions & 0 deletions conans/test/functional/generators/cmake_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import textwrap
import unittest

import pytest
from nose.plugins.attrib import attr

from conans.client.tools import replace_in_file
Expand Down Expand Up @@ -72,6 +73,7 @@ def package_id(self):
self.assertIn("Conan: Checking correct version:", client.out)

@attr("slow")
@pytest.mark.slow
@unittest.skipUnless(platform.system() == "Windows", "Requires MSBuild")
def test_skip_check_if_toolset(self):
file_content = textwrap.dedent("""
Expand Down Expand Up @@ -102,6 +104,7 @@ def build(self):
self.assertIn("Conan: Skipping compiler check: Declared 'compiler.toolset'", client.out)

@attr('slow')
@pytest.mark.slow
def test_no_output(self):
client = TestClient()
client.run("new Test/1.0 --sources")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import textwrap
import unittest

import pytest
from nose.plugins.attrib import attr

from conans.model.ref import ConanFileReference
Expand All @@ -11,6 +12,7 @@


@attr('slow')
@pytest.mark.slow
class CMakeGeneratorsWithComponentsTest(unittest.TestCase):

@staticmethod
Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/generators/make_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import platform
import unittest

import pytest
from nose.plugins.attrib import attr

from conans.client.tools import replace_in_file
Expand All @@ -11,6 +12,7 @@
class MakeGeneratorTest(unittest.TestCase):

@attr('slow')
@pytest.mark.slow
@unittest.skipUnless(platform.system() == "Linux", "Requires make")
def test_complete_creation_reuse(self):
client = TestClient(path_with_spaces=False)
Expand Down
Loading

0 comments on commit 4eb8f02

Please sign in to comment.