mirror of
https://github.com/certbot/certbot.git
synced 2026-07-28 00:35:50 +02:00
Automatically run test files with pytest (#9576)
* Switch to pytest
git grep -l unittest.main | xargs sed -i 's/unittest.main()/sys.exit(pytest.main([__file__]))/g'
git ls-files -m | xargs -I {} sh -c "echo 'import sys\nimport pytest' >> '{}'"
isort --float-to-top .
* add pytest dep
* use sys.argv
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
"""Tests for certbot.plugins.common."""
|
||||
import functools
|
||||
import shutil
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import josepy as jose
|
||||
import pytest
|
||||
|
||||
from acme import challenges
|
||||
from certbot import achallenges
|
||||
@@ -366,4 +368,4 @@ class InstallVersionControlledFileTest(test_util.TempDirTestCase):
|
||||
self.assertIs(mock_logger.warning.called, False)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
"""Tests for certbot._internal.plugins.disco."""
|
||||
import functools
|
||||
import string
|
||||
import sys
|
||||
from typing import List
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pkg_resources
|
||||
import pytest
|
||||
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
@@ -271,4 +273,4 @@ class PluginsRegistryTest(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
"""Tests for certbot.plugins.dns_common_lexicon."""
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from certbot.plugins import dns_common_lexicon
|
||||
from certbot.plugins import dns_test_common_lexicon
|
||||
|
||||
@@ -23,4 +26,4 @@ class LexiconClientTest(unittest.TestCase, dns_test_common_lexicon.BaseLexiconCl
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
import collections
|
||||
import logging
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from certbot import errors
|
||||
from certbot import util
|
||||
from certbot.compat import os
|
||||
@@ -233,4 +236,4 @@ class DomainNameGuessTest(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"""Tests for new style enhancements"""
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from certbot._internal.plugins import null
|
||||
from certbot.plugins import enhancements
|
||||
import certbot.tests.util as test_util
|
||||
@@ -59,4 +62,4 @@ class EnhancementTest(test_util.ConfigTestCase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
@@ -4,6 +4,8 @@ import textwrap
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from acme import challenges
|
||||
from certbot import errors
|
||||
from certbot.compat import filesystem
|
||||
@@ -159,4 +161,4 @@ class AuthenticatorTest(test_util.TempDirTestCase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"""Tests for certbot._internal.plugins.null."""
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class InstallerTest(unittest.TestCase):
|
||||
"""Tests for certbot._internal.plugins.null.Installer."""
|
||||
@@ -17,4 +20,4 @@ class InstallerTest(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
@@ -4,6 +4,8 @@ from typing import List
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot._internal.display import obj as display_obj
|
||||
@@ -261,4 +263,4 @@ class TestChooseConfiguratorPlugins(unittest.TestCase):
|
||||
self.assertEqual(auth.name, "apache")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Tests for certbot._internal.plugins.standalone."""
|
||||
import errno
|
||||
import socket
|
||||
import sys
|
||||
from typing import Dict
|
||||
from typing import Set
|
||||
from typing import Tuple
|
||||
@@ -9,6 +10,7 @@ from unittest import mock
|
||||
|
||||
import josepy as jose
|
||||
import OpenSSL.crypto
|
||||
import pytest
|
||||
|
||||
from acme import challenges
|
||||
from acme import standalone as acme_standalone
|
||||
@@ -185,4 +187,4 @@ class AuthenticatorTest(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
"""Tests for certbot.plugins.storage.PluginStorage"""
|
||||
import json
|
||||
import sys
|
||||
from typing import Iterable
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from certbot import errors
|
||||
from certbot.compat import filesystem
|
||||
from certbot.compat import os
|
||||
@@ -117,4 +120,4 @@ class PluginStorageTest(test_util.ConfigTestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"""Tests for certbot.plugins.util."""
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from certbot.compat import os
|
||||
|
||||
|
||||
@@ -41,4 +44,4 @@ class PathSurgeryTest(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
@@ -6,11 +6,13 @@ import argparse
|
||||
import errno
|
||||
import json
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import josepy as jose
|
||||
import pytest
|
||||
|
||||
from acme import challenges
|
||||
from certbot import achallenges
|
||||
@@ -360,4 +362,4 @@ class WebrootActionTest(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover
|
||||
|
||||
Reference in New Issue
Block a user