Модуль Python не перезагружается после importlib.reload () - PullRequest
0 голосов
/ 30 октября 2019

Я недавно изменил функцию в импортированном модуле, чтобы получить один аргумент. Однако Python, похоже, не распознает это изменение, несмотря на попытку перезагрузить модуль.

# config.py in bettered package
def read_config(config: str = None) -> ConfigParser:
    """Process and check a given configuration file.
    Raises:
        FileNotFoundError: No configuration file found.
        ValueError: Configuration value error.
    Returns:
        Complete ConfigParser object.
    """
    config = ConfigParser()

    if config:
        config_location = config
    else:
        config_location = CONFIG_LOCATIONS

    files_read = config.read(config_location)
    if not files_read:
        raise FileNotFoundError('No configuration file at the following '
                                f'location(s): {config_location}')

    _check_config(config)

    return config
"""Test module for the configuration file."""

import pytest

from bettered import config
import importlib
importlib.reload(config)


def test_config_exists():
    """Test FileNotFoundError raised when no configuration file found."""
    with pytest.raises(FileNotFoundError):
        config.read_config('')
$ pytest
   def test_config_exists():
        """Test FileNotFoundError raised when no configuration file found."""
        with pytest.raises(FileNotFoundError):
>           config.read_config('')
E           TypeError: read_config() takes 0 positional arguments but 1 was given

Что дает?

1 Ответ

0 голосов
/ 30 октября 2019

Единственное решение, которое я нашел, было переустановить мой пакет pip3 install -e .

Похоже, должен быть лучший способ.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...