Skip to content

Commit

Permalink
⚡🔨refactor(tests): add skipif marker to all test modules
Browse files Browse the repository at this point in the history
Ensured that all tests run with compatible version of python (3.8 or higher)
Closes #47
  • Loading branch information
MEHRSHAD-MIRSHEKARY committed Aug 28, 2024
1 parent d5f3d20 commit 0011af7
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 14 deletions.
9 changes: 8 additions & 1 deletion tests/commands/test_send_logs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import shutil
import sys
import tempfile
from unittest.mock import ANY, Mock, patch

Expand All @@ -8,7 +9,13 @@
from django.core.management import call_command
from django.test import TestCase

pytestmark = [pytest.mark.commands, pytest.mark.commands_send_logs]
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [
pytest.mark.commands,
pytest.mark.commands_send_logs,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class SendLogsCommandTests(TestCase):
Expand Down
8 changes: 7 additions & 1 deletion tests/filters/test_log_level_filter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import logging
import sys

import pytest

from django_logging.filters import LoggingLevelFilter
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.filters, pytest.mark.filters_level_filter]
pytestmark = [
pytest.mark.filters,
pytest.mark.filters_level_filter,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestLoggingLevelFilter:
Expand Down
8 changes: 7 additions & 1 deletion tests/formatters/test_colored_formatter.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import logging
import sys
from unittest.mock import MagicMock, patch

import pytest

from django_logging.formatters import ColoredFormatter
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.formatters, pytest.mark.colored_formatter]
pytestmark = [
pytest.mark.formatters,
pytest.mark.colored_formatter,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestColoredFormatter:
Expand Down
8 changes: 7 additions & 1 deletion tests/handlers/test_email_handler.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import logging
import sys
from unittest.mock import ANY, MagicMock, patch

import pytest
from django.conf import settings

from django_logging.handlers.email_handler import EmailHandler
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.handlers, pytest.mark.email_handler]
pytestmark = [
pytest.mark.handlers,
pytest.mark.email_handler,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestEmailHandler:
Expand Down
8 changes: 7 additions & 1 deletion tests/middleware/test_request_middleware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import sys
from unittest.mock import Mock

import pytest
Expand All @@ -7,8 +8,13 @@
from django.test import RequestFactory

from django_logging.middleware import RequestLogMiddleware
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.middleware, pytest.mark.request_middleware]
pytestmark = [
pytest.mark.middleware,
pytest.mark.request_middleware,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestRequestMiddleware:
Expand Down
8 changes: 7 additions & 1 deletion tests/settings/test_checks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from typing import Generator, List
from unittest.mock import patch

Expand All @@ -6,8 +7,13 @@
from django.core.checks import Error

from django_logging.settings.checks import check_logging_settings
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.settings, pytest.mark.settings_checks]
pytestmark = [
pytest.mark.settings,
pytest.mark.settings_checks,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestChecks:
Expand Down
8 changes: 7 additions & 1 deletion tests/settings/test_conf.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import os
import sys
from shutil import rmtree
from unittest import mock

import pytest

from django_logging.constants import FORMAT_OPTIONS
from django_logging.settings.conf import LogConfig, LogManager
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.settings, pytest.mark.settings_conf]
pytestmark = [
pytest.mark.settings,
pytest.mark.settings_conf,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestConf:
Expand Down
8 changes: 7 additions & 1 deletion tests/utils/test_context_manager.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import logging
import sys
from unittest import mock

import pytest

from django_logging.utils.context_manager import _restore_logging_config, config_setup
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.utils, pytest.mark.utils_context_manager]
pytestmark = [
pytest.mark.utils,
pytest.mark.utils_context_manager,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestContextManager:
Expand Down
8 changes: 7 additions & 1 deletion tests/utils/test_email_notifier.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import sys
import threading
from smtplib import SMTPException
from unittest.mock import ANY, MagicMock

import pytest

from django_logging.utils.log_email_notifier.notifier import send_email_async
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.utils, pytest.mark.utils_email_notifier]
pytestmark = [
pytest.mark.utils,
pytest.mark.utils_email_notifier,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestEmailNotifier:
Expand Down
8 changes: 7 additions & 1 deletion tests/utils/test_get_conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from typing import Dict
from unittest.mock import patch

Expand All @@ -10,8 +11,13 @@
is_initialization_message_enabled,
use_email_notifier_template,
)
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.utils, pytest.mark.utils_get_conf]
pytestmark = [
pytest.mark.utils,
pytest.mark.utils_get_conf,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestGetConf:
Expand Down
8 changes: 7 additions & 1 deletion tests/utils/test_log_and_notify.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import logging
import sys
from typing import Dict
from unittest.mock import MagicMock, patch

import pytest
from django.conf import settings

from django_logging.utils.log_email_notifier.log_and_notify import log_and_notify_admin
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.utils, pytest.mark.utils_log_and_notify]
pytestmark = [
pytest.mark.utils,
pytest.mark.utils_log_and_notify,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestLogAndNotify:
Expand Down
8 changes: 7 additions & 1 deletion tests/utils/test_set_conf.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import os
import sys
from unittest.mock import MagicMock, patch

import pytest

from django_logging.constants.ansi_colors import AnsiColors
from django_logging.utils.set_conf import set_config
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.utils, pytest.mark.utils_set_conf]
pytestmark = [
pytest.mark.utils,
pytest.mark.utils_set_conf,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestSetConf:
Expand Down
8 changes: 7 additions & 1 deletion tests/validators/test_config_validators.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from unittest.mock import patch

import pytest
Expand All @@ -12,8 +13,13 @@
validate_format_string,
validate_log_levels,
)
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.validators, pytest.mark.config_validator]
pytestmark = [
pytest.mark.validators,
pytest.mark.config_validator,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestConfigValidator:
Expand Down
8 changes: 7 additions & 1 deletion tests/validators/test_email_settings_validator.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import sys
from typing import Dict
from unittest.mock import patch

import pytest
from django.conf import settings

from django_logging.validators.email_settings_validator import check_email_settings
from tests.constants import PYTHON_VERSION, PYTHON_VERSION_REASON

pytestmark = [pytest.mark.validators, pytest.mark.email_settings_validator]
pytestmark = [
pytest.mark.validators,
pytest.mark.email_settings_validator,
pytest.mark.skipif(sys.version_info < PYTHON_VERSION, reason=PYTHON_VERSION_REASON),
]


class TestEmailSettingsValidator:
Expand Down

0 comments on commit 0011af7

Please sign in to comment.