instance_id
stringlengths
10
57
patch
stringlengths
261
37.7k
repo
stringlengths
7
53
base_commit
stringlengths
40
40
hints_text
stringclasses
301 values
test_patch
stringlengths
212
2.22M
problem_statement
stringlengths
23
37.7k
version
stringclasses
1 value
environment_setup_commit
stringlengths
40
40
FAIL_TO_PASS
listlengths
1
4.94k
PASS_TO_PASS
listlengths
0
7.82k
meta
dict
created_at
stringlengths
25
25
license
stringclasses
8 values
__index_level_0__
int64
0
6.41k
postlund__pyatv-944
diff --git a/pyatv/mrp/player_state.py b/pyatv/mrp/player_state.py index d5e626cb..4615edb3 100644 --- a/pyatv/mrp/player_state.py +++ b/pyatv/mrp/player_state.py @@ -8,10 +8,12 @@ from copy import deepcopy from typing import Dict, Optional, List from pyatv.mrp import protobuf as pb - +from pyatv.mrp.protocol import MrpProtocol _LOGGER = logging.getLogger(__name__) +DEFAULT_PLAYER_ID = "MediaRemote-DefaultPlayer" + class PlayerState: """Represent what is currently playing on a device.""" @@ -129,21 +131,50 @@ class PlayerState: class Client: """Represent an MRP media player client.""" - def __init__(self, client: pb.NowPlayingClient): + def __init__(self, client: pb.NowPlayingClient) -> None: """Initialize a new Client instance.""" self.bundle_identifier: str = client.bundleIdentifier self.display_name: Optional[str] = None + self._active_player: Optional[PlayerState] = None self.players: Dict[str, PlayerState] = {} self.supported_commands: List[pb.CommandInfo] = [] self.update(client) - def handle_set_default_supported_commands(self, supported_commands): + @property + def active_player(self) -> PlayerState: + """Return currently active player.""" + if self._active_player is None: + if DEFAULT_PLAYER_ID in self.players: + return self.players[DEFAULT_PLAYER_ID] + return PlayerState(self, pb.NowPlayingPlayer()) + return self._active_player + + def get_player(self, player: pb.NowPlayingPlayer) -> PlayerState: + """Get state for a player.""" + if player.identifier not in self.players: + self.players[player.identifier] = PlayerState(self, player) + return self.players[player.identifier] + + def handle_set_default_supported_commands(self, supported_commands) -> None: """Update default supported commands for client.""" self.supported_commands = deepcopy( supported_commands.supportedCommands.supportedCommands ) - def update(self, client: pb.NowPlayingClient): + def handle_set_now_playing_player(self, player: pb.NowPlayingPlayer) -> None: + """Handle change of now playing player.""" + self._active_player = self.get_player(player) + + if self.active_player.is_valid: + _LOGGER.debug( + "Active player is now %s (%s)", + self.active_player.identifier, + self.active_player.display_name, + ) + else: + _LOGGER.debug("Active player no longer set") + + def update(self, client: pb.NowPlayingClient) -> None: """Update client metadata.""" self.display_name = client.displayName or self.display_name @@ -151,12 +182,11 @@ class Client: class PlayerStateManager: """Manage state of all media players.""" - def __init__(self, protocol): + def __init__(self, protocol: MrpProtocol): """Initialize a new PlayerStateManager instance.""" self.protocol = protocol self.volume_controls_available = None self._active_client = None - self._active_player = None self._clients: Dict[str, Client] = {} self._listener = None self._add_listeners() @@ -185,12 +215,7 @@ class PlayerStateManager: def get_player(self, player_path: pb.PlayerPath) -> PlayerState: """Return player based on a player path.""" - client = self.get_client(player_path.client) - - player_id = player_path.player.identifier - if player_id not in client.players: - client.players[player_id] = PlayerState(client, player_path.player) - return client.players[player_id] + return self.get_client(player_path.client).get_player(player_path.player) @property def listener(self): @@ -213,16 +238,10 @@ class PlayerStateManager: return self._active_client @property - def playing(self): + def playing(self) -> PlayerState: """Player state for active media player.""" - if self._active_player: - return self._active_player if self._active_client: - default_player = self._active_client.players.get( - "MediaRemote-DefaultPlayer" - ) - if default_player: - return default_player + return self._active_client.active_player return PlayerState(Client(pb.NowPlayingClient()), pb.NowPlayingPlayer()) async def _handle_set_state(self, message, _): @@ -249,18 +268,12 @@ class PlayerStateManager: await self._state_updated() async def _handle_set_now_playing_player(self, message, _): - self._active_player = self.get_player(message.inner().playerPath) + set_now_playing = message.inner() - if self._active_player.is_valid: - _LOGGER.debug( - "Active player is now %s (%s)", - self._active_player.identifier, - self._active_player.display_name, - ) - else: - _LOGGER.debug("Active player no longer set") + client = self.get_client(set_now_playing.playerPath.client) + client.handle_set_now_playing_player(set_now_playing.playerPath.player) - await self._state_updated() + await self._state_updated(client=client) async def _handle_remove_client(self, message, _): client_to_remove = message.inner().client @@ -282,16 +295,9 @@ class PlayerStateManager: del client.players[player.identifier] player.parent = None - removed = False - if player == self._active_player: - self._active_player = None - removed = True - if client == self._active_client: - self._active_client = None - removed = True - - if removed: - await self._state_updated() + if player == client.active_player: + client._active_player = None + await self._state_updated(client=client) async def _handle_set_default_supported_commands(self, message, _): supported_commands = message.inner()
postlund/pyatv
7e3bcf55a3f869eb60afd0b57e9bb8fee273f0b1
diff --git a/tests/mrp/test_player_state.py b/tests/mrp/test_player_state.py index 7b4de2ff..9a7245dd 100644 --- a/tests/mrp/test_player_state.py +++ b/tests/mrp/test_player_state.py @@ -14,6 +14,8 @@ CLIENT_ID_2 = "client_id_2" PLAYER_ID_1 = "player_id_1" PLAYER_NAME_1 = "player_name_1" +DEFAULT_PLAYER = "MediaRemote-DefaultPlayer" + def set_path( message, @@ -252,11 +254,27 @@ async def test_set_now_playing_client(psm, protocol, listener): @pytest.mark.asyncio -async def test_set_now_playing_player(psm, protocol, listener): +async def test_set_now_playing_player_when_no_client(psm, protocol, listener): msg = set_path(messages.create(pb.SET_NOW_PLAYING_PLAYER_MESSAGE)) await protocol.inject(msg) - assert listener.call_count == 1 + assert listener.call_count == 0 + + assert not psm.playing.identifier + assert not psm.playing.display_name + + [email protected] +async def test_set_now_playing_player_for_active_client(psm, protocol, listener): + msg = messages.create(pb.SET_NOW_PLAYING_CLIENT_MESSAGE) + client = msg.inner().client + client.bundleIdentifier = CLIENT_ID_1 + await protocol.inject(msg) + + msg = set_path(messages.create(pb.SET_NOW_PLAYING_PLAYER_MESSAGE)) + await protocol.inject(msg) + + assert listener.call_count == 2 assert psm.playing.identifier == PLAYER_ID_1 assert psm.playing.display_name == PLAYER_NAME_1 @@ -268,7 +286,7 @@ async def test_default_player_when_only_client_set(psm, protocol, listener): await protocol.inject(msg) msg = set_path( messages.create(pb.SET_STATE_MESSAGE), - player_id="MediaRemote-DefaultPlayer", + player_id=DEFAULT_PLAYER, player_name="Default Name", ) await protocol.inject(msg) @@ -278,7 +296,7 @@ async def test_default_player_when_only_client_set(psm, protocol, listener): client.bundleIdentifier = CLIENT_ID_1 await protocol.inject(msg) - assert psm.playing.identifier == "MediaRemote-DefaultPlayer" + assert psm.playing.identifier == DEFAULT_PLAYER assert psm.playing.display_name == "Default Name" @@ -289,14 +307,21 @@ async def test_set_state_calls_active_listener(psm, protocol, listener): assert listener.call_count == 1 + msg = messages.create(pb.SET_NOW_PLAYING_CLIENT_MESSAGE) + client = msg.inner().client + client.bundleIdentifier = CLIENT_ID_1 + await protocol.inject(msg) + + assert listener.call_count == 2 + now_playing = set_path(messages.create(pb.SET_NOW_PLAYING_PLAYER_MESSAGE)) await protocol.inject(now_playing) - assert listener.call_count == 2 + assert listener.call_count == 3 await protocol.inject(set_state) - assert listener.call_count == 3 + assert listener.call_count == 4 @pytest.mark.asyncio @@ -312,14 +337,21 @@ async def test_content_item_update_calls_active_listener(psm, protocol, listener assert listener.call_count == 2 + msg = messages.create(pb.SET_NOW_PLAYING_CLIENT_MESSAGE) + client = msg.inner().client + client.bundleIdentifier = CLIENT_ID_1 + await protocol.inject(msg) + + assert listener.call_count == 3 + now_playing = set_path(messages.create(pb.SET_NOW_PLAYING_PLAYER_MESSAGE)) await protocol.inject(now_playing) - assert listener.call_count == 3 + assert listener.call_count == 4 await protocol.inject(update_item) - assert listener.call_count == 4 + assert listener.call_count == 5 @pytest.mark.asyncio @@ -388,6 +420,11 @@ async def test_remove_active_player(psm, protocol, listener): msg = set_path(messages.create(pb.SET_STATE_MESSAGE)) await protocol.inject(msg) + msg = messages.create(pb.SET_NOW_PLAYING_CLIENT_MESSAGE) + client = msg.inner().client + client.bundleIdentifier = CLIENT_ID_1 + await protocol.inject(msg) + msg = set_path(messages.create(pb.SET_NOW_PLAYING_PLAYER_MESSAGE)) await protocol.inject(msg) @@ -396,12 +433,12 @@ async def test_remove_active_player(psm, protocol, listener): remove = set_path(messages.create(pb.REMOVE_PLAYER_MESSAGE)) await protocol.inject(remove) - assert listener.call_count == 3 + assert listener.call_count == 4 assert not psm.playing.is_valid -async def test_remove_client_if_belongs_to_active_player(psm, protocol, listener): - msg = set_path(messages.create(pb.SET_STATE_MESSAGE)) +async def test_remove_active_player_reverts_to_default(psm, protocol, listener): + msg = set_path(messages.create(pb.SET_STATE_MESSAGE), player_id=DEFAULT_PLAYER) await protocol.inject(msg) msg = set_path(messages.create(pb.SET_NOW_PLAYING_PLAYER_MESSAGE)) @@ -412,11 +449,14 @@ async def test_remove_client_if_belongs_to_active_player(psm, protocol, listener client.bundleIdentifier = CLIENT_ID_1 await protocol.inject(msg) + assert listener.call_count == 2 + assert psm.playing.identifier == PLAYER_ID_1 + remove = set_path(messages.create(pb.REMOVE_PLAYER_MESSAGE)) await protocol.inject(remove) - assert psm.client is None - assert listener.call_count == 4 + assert listener.call_count == 3 + assert psm.playing.identifier == DEFAULT_PLAYER @pytest.mark.asyncio
Wrong state reported for MRP **Describe the bug** Due to me misunderstanding how clients and players work, I introduced a bug when I re-wrote the player management. I assumed that a `SetNowPlayingPlayer` always changed the currently active player. That is not true as it only changes the active player for a particular client. A `SetNowPlayingClient` determines what is actually currently playing. I need to change so that I keep track of an active player per client. **To Reproduce** This is quite easy to trigger by just watching content in various apps. After some time (usually quite fast), the bug will happen. The metadata will show something from another app usually. **Expected behavior** Correct metadata for what is currently playing is shown. **System Setup (please complete the following information):** - OS: any - Python: any - pyatv: master - Apple TV: Apple TV 4K tvOS 14.3 **Additional context** Introduced in #915
0.0
7e3bcf55a3f869eb60afd0b57e9bb8fee273f0b1
[ "tests/mrp/test_player_state.py::test_set_now_playing_player_when_no_client" ]
[ "tests/mrp/test_player_state.py::test_get_client_and_player", "tests/mrp/test_player_state.py::test_no_metadata", "tests/mrp/test_player_state.py::test_metadata_single_item", "tests/mrp/test_player_state.py::test_metadata_multiple_items", "tests/mrp/test_player_state.py::test_metadata_no_item_identifier", "tests/mrp/test_player_state.py::test_metadata_item_identifier", "tests/mrp/test_player_state.py::test_get_metadata_field", "tests/mrp/test_player_state.py::test_content_item_update", "tests/mrp/test_player_state.py::test_get_command_info", "tests/mrp/test_player_state.py::test_playback_state_without_rate", "tests/mrp/test_player_state.py::test_playback_state_playing", "tests/mrp/test_player_state.py::test_playback_state_seeking", "tests/mrp/test_player_state.py::test_change_listener", "tests/mrp/test_player_state.py::test_set_now_playing_client", "tests/mrp/test_player_state.py::test_set_now_playing_player_for_active_client", "tests/mrp/test_player_state.py::test_default_player_when_only_client_set", "tests/mrp/test_player_state.py::test_set_state_calls_active_listener", "tests/mrp/test_player_state.py::test_content_item_update_calls_active_listener", "tests/mrp/test_player_state.py::test_update_client", "tests/mrp/test_player_state.py::test_volume_control_availability", "tests/mrp/test_player_state.py::test_set_default_supported_commands" ]
{ "failed_lite_validators": [ "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2021-01-25 21:33:16+00:00
mit
4,635
postlund__pyatv-978
diff --git a/pyatv/mrp/protocol.py b/pyatv/mrp/protocol.py index 9e31abcf..c152b2d3 100644 --- a/pyatv/mrp/protocol.py +++ b/pyatv/mrp/protocol.py @@ -14,6 +14,7 @@ from pyatv.mrp.srp import Credentials _LOGGER = logging.getLogger(__name__) HEARTBEAT_INTERVAL = 30 +HEARTBEAT_RETRIES = 1 # One regular attempt + retries Listener = namedtuple("Listener", "func data") OutstandingMessage = namedtuple("OutstandingMessage", "semaphore response") @@ -23,10 +24,14 @@ async def heartbeat_loop(protocol): """Periodically send heartbeat messages to device.""" _LOGGER.debug("Starting heartbeat loop") count = 0 + attempts = 0 message = messages.create(protobuf.ProtocolMessage.SEND_COMMAND_MESSAGE) while True: try: - await asyncio.sleep(HEARTBEAT_INTERVAL) + # Re-attempts are made with no initial delay to more quickly + # recover a failed heartbeat (if possible) + if attempts == 0: + await asyncio.sleep(HEARTBEAT_INTERVAL) _LOGGER.debug("Sending periodic heartbeat %d", count) await protocol.send_and_receive(message) @@ -34,11 +39,18 @@ async def heartbeat_loop(protocol): except asyncio.CancelledError: break except Exception: - _LOGGER.exception(f"heartbeat {count} failed") - protocol.connection.close() - break + attempts += 1 + if attempts > HEARTBEAT_RETRIES: + _LOGGER.error(f"heartbeat {count} failed after {attempts} tries") + protocol.connection.close() + break + else: + _LOGGER.debug(f"heartbeat {count} failed") else: + attempts = 0 + finally: count += 1 + _LOGGER.debug("Stopping heartbeat loop at %d", count)
postlund/pyatv
b0eaaef67115544e248d219629c8171d5221d687
diff --git a/tests/mrp/test_protocol.py b/tests/mrp/test_protocol.py index 8c7e8c63..20043675 100644 --- a/tests/mrp/test_protocol.py +++ b/tests/mrp/test_protocol.py @@ -1,13 +1,20 @@ """Unittests for pyatv.mrp.protocol.""" +from unittest.mock import MagicMock + import pytest from pyatv.conf import MrpService from pyatv.const import Protocol from pyatv.mrp.connection import MrpConnection -from pyatv.mrp.protocol import MrpProtocol +from pyatv.mrp.protocol import ( + HEARTBEAT_INTERVAL, + HEARTBEAT_RETRIES, + MrpProtocol, + heartbeat_loop, +) from pyatv.mrp.srp import SRPAuthHandler -from tests.utils import until, stub_sleep +from tests.utils import until, total_sleep_time from tests.fake_device import FakeAppleTV @@ -37,3 +44,15 @@ async def test_heartbeat_loop(mrp_atv, mrp_protocol): mrp_state = mrp_atv.get_state(Protocol.MRP) await until(lambda: mrp_state.heartbeat_count >= 3) + + [email protected] +async def test_heartbeat_fail_closes_connection(stub_sleep): + protocol = MagicMock() + protocol.send_and_receive.side_effect = Exception() + + await heartbeat_loop(protocol) + assert protocol.send_and_receive.call_count == 1 + HEARTBEAT_RETRIES + assert total_sleep_time() == HEARTBEAT_INTERVAL + + protocol.connection.close.assert_called_once() diff --git a/tests/utils.py b/tests/utils.py index 63e3fc17..6734d13c 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -16,6 +16,7 @@ from aiohttp import ClientSession async def _fake_sleep(time: float = None, loop=None): async def dummy(): _fake_sleep._sleep_time.insert(0, time) + _fake_sleep._total_sleep += time await asyncio.ensure_future(dummy()) @@ -28,6 +29,7 @@ def stub_sleep(fn=None) -> float: if asyncio.sleep == _fake_sleep: if not hasattr(asyncio.sleep, "_sleep_time"): asyncio.sleep._sleep_time = [0.0] + asyncio.sleep._total_sleep = 0.0 if len(asyncio.sleep._sleep_time) == 1: return asyncio.sleep._sleep_time[0] return asyncio.sleep._sleep_time.pop() @@ -35,13 +37,21 @@ def stub_sleep(fn=None) -> float: return 0.0 -def unstub_sleep(): +def unstub_sleep() -> None: """Restore original asyncio.sleep method.""" if asyncio.sleep == _fake_sleep: asyncio.sleep._sleep_time = [0.0] + asyncio.sleep._total_sleep = 0.0 asyncio.sleep = real_sleep +def total_sleep_time() -> float: + """Return total amount of fake time slept.""" + if asyncio.sleep == _fake_sleep: + return _fake_sleep._total_sleep + return 0.0 + + async def simple_get(url): """Perform a GET-request to a specified URL.""" async with ClientSession() as session:
Add retries for heartbeats (MRP) **What feature would you like?** When a heartbeat fails, an error is logged and the connection is closed. Generally this is good, but in case the response happens to be delayed long enough (even though nothing is wrong), this is quite pessimistic and it's probably a good idea to make another try before failing. Do not impose an initial delay on the retry though (just retry immediately) as we still want to fail as early as possible in case of an actual problem. **Describe the solution you'd like** From the description above: make a retry immediately when a heartbeat fails. Only log error if retry also fails. **Any other information to share?** Heartbeat errors seems to happen sporadically and I believe there's not actually a problem in most cases. This is an attempt to recover in those cases, but it's still not a very well tested method so I can't be sure that it works.
0.0
b0eaaef67115544e248d219629c8171d5221d687
[ "tests/mrp/test_protocol.py::test_heartbeat_fail_closes_connection" ]
[]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2021-02-23 08:16:31+00:00
mit
4,636
potassco__clorm-131
diff --git a/clorm/orm/_typing.py b/clorm/orm/_typing.py index f896f8a..473272a 100644 --- a/clorm/orm/_typing.py +++ b/clorm/orm/_typing.py @@ -1,5 +1,5 @@ import sys -from typing import Any, Optional, Tuple, Type, TypeVar, Union, cast +from typing import Any, Dict, ForwardRef, Optional, Tuple, Type, TypeVar, Union, _eval_type, cast from clingo import Symbol @@ -58,3 +58,37 @@ elif sys.version_info < (3, 8): res = (list(res[:-1]), res[-1]) return res return getattr(t, "__args__", ()) + + +def resolve_annotations( + raw_annotations: Dict[str, Type[Any]], module_name: Optional[str] = None +) -> Dict[str, Type[Any]]: + """ + Taken from https://github.com/pydantic/pydantic/blob/1.10.X-fixes/pydantic/typing.py#L376 + + Resolve string or ForwardRef annotations into type objects if possible. + """ + base_globals: Optional[Dict[str, Any]] = None + if module_name: + try: + module = sys.modules[module_name] + except KeyError: + # happens occasionally, see https://github.com/pydantic/pydantic/issues/2363 + pass + else: + base_globals = module.__dict__ + + annotations = {} + for name, value in raw_annotations.items(): + if isinstance(value, str): + if (3, 10) > sys.version_info >= (3, 9, 8) or sys.version_info >= (3, 10, 1): + value = ForwardRef(value, is_argument=False, is_class=True) + else: + value = ForwardRef(value, is_argument=False) + try: + value = _eval_type(value, base_globals, None) + except NameError: + # this is ok, it can be fixed with update_forward_refs + pass + annotations[name] = value + return annotations diff --git a/clorm/orm/atsyntax.py b/clorm/orm/atsyntax.py index 1e1b910..97d3eff 100644 --- a/clorm/orm/atsyntax.py +++ b/clorm/orm/atsyntax.py @@ -6,9 +6,9 @@ import collections.abc as cabc import functools import inspect -from typing import Any, Callable, List, Sequence, Tuple, Type +from typing import Any, Callable, List, Sequence, Tuple, Type, Union -from .core import BaseField, get_field_definition, infer_field_definition +from .core import BaseField, get_field_definition, infer_field_definition, resolve_annotations __all__ = [ "TypeCastSignature", @@ -36,6 +36,7 @@ class TypeCastSignature(object): r"""Defines a signature for converting to/from Clingo data types. Args: + module: Name of the module where the signature is defined sigs(\*sigs): A list of signature elements. - Inputs. Match the sub-elements [:-1] define the input signature while @@ -54,9 +55,9 @@ class TypeCastSignature(object): pytocl = lambda dt: dt.strftime("%Y%m%d") cltopy = lambda s: datetime.datetime.strptime(s,"%Y%m%d").date() - drsig = TypeCastSignature(DateField, DateField, [DateField]) + drsig = TypeCastSignature(DateField, DateField, [DateField], module = "__main__") - @drsig.make_clingo_wrapper + @drsig.wrap_function def date_range(start, end): return [ start + timedelta(days=x) for x in range(0,end-start) ] @@ -97,24 +98,29 @@ class TypeCastSignature(object): return _is_output_field(se[0]) return _is_output_field(se) - def __init__(self, *sigs: Any) -> None: + def __init__(self, *sigs: Any, module: Union[str, None] = None) -> None: + module = self.__module__ if module is None else module + def _validate_basic_sig(sig): if TypeCastSignature._is_input_element(sig): return True raise TypeError( - ("TypeCastSignature element {} must be a BaseField " "subclass".format(sig)) + "TypeCastSignature element {} must be a BaseField subclass".format(sig) ) insigs: List[Type[BaseField]] = [] for s in sigs[:-1]: field = None try: - field = infer_field_definition(s, "") + resolved = resolve_annotations({"__tmp__": s}, module)["__tmp__"] + field = infer_field_definition(resolved, "") except Exception: pass insigs.append(field if field else type(get_field_definition(s))) try: - self._outsig = infer_field_definition(sigs[-1], "") or sigs[-1] + outsig = sigs[-1] + outsig = resolve_annotations({"__tmp__": outsig}, module)["__tmp__"] + self._outsig = infer_field_definition(outsig, "") or outsig except Exception: self._outsig = sigs[-1] @@ -327,7 +333,7 @@ def make_function_asp_callable(*args: Any) -> _AnyCallable: # A decorator function that adjusts for the given signature def _sig_decorate(func): - s = TypeCastSignature(*sigs) + s = TypeCastSignature(*sigs, module=func.__module__) return s.wrap_function(func) # If no function and sig then called as a decorator with arguments @@ -372,7 +378,7 @@ def make_method_asp_callable(*args: Any) -> _AnyCallable: # A decorator function that adjusts for the given signature def _sig_decorate(func): - s = TypeCastSignature(*sigs) + s = TypeCastSignature(*sigs, module=func.__module__) return s.wrap_method(func) # If no function and sig then called as a decorator with arguments @@ -479,7 +485,7 @@ class ContextBuilder(object): args = sigargs else: args = _get_annotations(fn) - s = TypeCastSignature(*args) + s = TypeCastSignature(*args, module=fn.__module__) self._add_function(fname, s, fn) return fn diff --git a/clorm/orm/core.py b/clorm/orm/core.py index b034dad..cec0826 100644 --- a/clorm/orm/core.py +++ b/clorm/orm/core.py @@ -47,7 +47,7 @@ from clorm.orm.types import ( TailListReversed, ) -from ._typing import AnySymbol, get_args, get_origin +from ._typing import AnySymbol, get_args, get_origin, resolve_annotations from .noclingo import ( Function, Number, @@ -2866,6 +2866,9 @@ def infer_field_definition(type_: Type[Any], module: str) -> Optional[Type[BaseF tuple(infer_field_definition(arg, module) for arg in args), module ) ) + if not isinstance(type_, type): + return None + # from here on only check for subclass if issubclass(type_, enum.Enum): # if type_ just inherits from Enum is IntegerField, otherwise find appropriate Field field = ( @@ -3000,13 +3003,11 @@ def _make_predicatedefn( fields_from_annotations = {} module = namespace.get("__module__", None) - for name, type_ in namespace.get("__annotations__", {}).items(): + for name, type_ in resolve_annotations(namespace.get("__annotations__", {}), module).items(): if name in fields_from_dct: # first check if FieldDefinition was assigned fields_from_annotations[name] = fields_from_dct[name] - else: - fdefn = infer_field_definition( - type_, module - ) # if not try to infer the definition based on the type + else: # if not try to infer the definition based on the type + fdefn = infer_field_definition(type_, module) if fdefn: fields_from_annotations[name] = fdefn elif inspect.isclass(type_):
potassco/clorm
3b3d795e36a6924a77fd5a4d73b71f102cc3e648
diff --git a/tests/__init__.py b/tests/__init__.py index 59808ff..ee924d0 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -8,6 +8,7 @@ import os os.environ["CLORM_NOCLINGO"] = "True" from .test_clingo import * +from .test_forward_ref import * from .test_json import * from .test_libdate import LibDateTestCase from .test_libtimeslot import * diff --git a/tests/test_forward_ref.py b/tests/test_forward_ref.py new file mode 100644 index 0000000..979898a --- /dev/null +++ b/tests/test_forward_ref.py @@ -0,0 +1,167 @@ +import importlib +import inspect +import secrets +import sys +import tempfile +import textwrap +import unittest +from contextlib import contextmanager +from pathlib import Path +from types import FunctionType + +from clingo import Number, String + +__all__ = [ + "ForwardRefTestCase", +] + + +def _extract_source_code_from_function(function): + if function.__code__.co_argcount: + raise RuntimeError(f"function {function.__qualname__} cannot have any arguments") + + code_lines = "" + body_started = False + for line in textwrap.dedent(inspect.getsource(function)).split("\n"): + if line.startswith("def "): + body_started = True + continue + elif body_started: + code_lines += f"{line}\n" + + return textwrap.dedent(code_lines) + + +def _create_module_file(code, tmp_path, name): + name = f"{name}_{secrets.token_hex(5)}" + path = Path(tmp_path, f"{name}.py") + path.write_text(code) + return name, str(path) + + +def create_module(tmp_path, method_name): + def run(source_code_or_function): + """ + Create module object, execute it and return + + :param source_code_or_function string or function with body as a source code for created module + + """ + if isinstance(source_code_or_function, FunctionType): + source_code = _extract_source_code_from_function(source_code_or_function) + else: + source_code = source_code_or_function + + module_name, filename = _create_module_file(source_code, tmp_path, method_name) + + spec = importlib.util.spec_from_file_location(module_name, filename, loader=None) + sys.modules[module_name] = module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + return run + + +class ForwardRefTestCase(unittest.TestCase): + def setUp(self): + @contextmanager + def f(source_code_or_function): + with tempfile.TemporaryDirectory() as tmp_path: + yield create_module(tmp_path, self._testMethodName)(source_code_or_function) + + self._create_module = f + + def test_postponed_annotations(self): + code = """ +from __future__ import annotations +from clorm import Predicate + +class P1(Predicate): + a: int + b: str +""" + with self._create_module(code) as module: + p = module.P1(a=3, b="42") + self.assertEqual(str(p), 'p1(3,"42")') + + def test_postponed_annotations_complex(self): + code = """ +from clorm import Predicate +from typing import Union + +class P1(Predicate): + a: int + b: str + +class P2(Predicate): + a: int + +class P3(Predicate): + a: 'Union[P1, P2]' +""" + with self._create_module(code) as module: + p = module.P3(a=module.P1(a=3, b="42")) + self.assertEqual(str(p), 'p3(p1(3,"42"))') + p = module.P3(a=module.P2(a=42)) + self.assertEqual(str(p), "p3(p2(42))") + + def test_forward_ref(self): + def module_(): + from typing import ForwardRef + + from clorm import Predicate + + class A(Predicate): + a: int + + ARef = ForwardRef("A") + + class B(Predicate): + a: ARef + + with self._create_module(module_) as module: + b = module.B(a=module.A(a=42)) + self.assertEqual(str(b), "b(a(42))") + + def test_forward_ref_list(self): + def module_(): + from typing import ForwardRef + + from clorm import HeadList, Predicate + + class A(Predicate): + a: int + + ARef = ForwardRef("A") + + class B(Predicate): + a: HeadList[ARef] + + with self._create_module(module_) as module: + b = module.B(a=[module.A(a=41), module.A(a=42)]) + self.assertEqual(str(b), "b((a(41),(a(42),())))") + + def test_forward_ref_asp_callable(self): + code = """ +from __future__ import annotations +from clorm import Predicate, make_function_asp_callable, make_method_asp_callable + +class P1(Predicate): + a: int + b: str + +@make_function_asp_callable +def f(a: int, b: str) -> P1: + return P1(a,b) + +class Context: + @make_method_asp_callable + def f(self, a: int, b: str) -> P1: + return P1(a,b) +""" + with self._create_module(code) as module: + p = module.f(Number(2), String("2")) + self.assertEqual(str(p), 'p1(2,"2")') + ctx = module.Context() + p = ctx.f(Number(2), String("2")) + self.assertEqual(str(p), 'p1(2,"2")')
Dealing with postponed evaluation of annotations Postponed evaluation of annotations is documented in PEP 563 https://peps.python.org/pep-0563/ Postponed evaluation of annotations can be enabled with `from __future__ import annotations` and will become mandatory in some future version of Python. The basic idea is that when the annotation is evaluated at runtime, it will appear as a string and not as the types that the strings represent. Because of this, using annotations for defining `Predicate` sub-classes or using annotations with function signature to define '@' ASP functions breaks when postponed evaluation of annotations is enabled. Dealing with this in Clorm may not be straightforward. See this Pydantic issue for some discussion: https://github.com/pydantic/pydantic/issues/2678. I think some of the issues raised could also apply to Clorm.
0.0
3b3d795e36a6924a77fd5a4d73b71f102cc3e648
[ "tests/__init__.py::ForwardRefTestCase::test_forward_ref", "tests/__init__.py::ForwardRefTestCase::test_forward_ref_asp_callable", "tests/__init__.py::ForwardRefTestCase::test_forward_ref_list", "tests/__init__.py::ForwardRefTestCase::test_postponed_annotations", "tests/__init__.py::ForwardRefTestCase::test_postponed_annotations_complex", "tests/test_forward_ref.py::ForwardRefTestCase::test_forward_ref", "tests/test_forward_ref.py::ForwardRefTestCase::test_forward_ref_asp_callable", "tests/test_forward_ref.py::ForwardRefTestCase::test_forward_ref_list", "tests/test_forward_ref.py::ForwardRefTestCase::test_postponed_annotations", "tests/test_forward_ref.py::ForwardRefTestCase::test_postponed_annotations_complex" ]
[ "tests/__init__.py::ClingoTestCase::test_basic_clingo_connection", "tests/__init__.py::ClingoTestCase::test_class_defs_are_equal", "tests/__init__.py::ClingoTestCase::test_control_and_model_wrapper", "tests/__init__.py::ClingoTestCase::test_control_model_integration", "tests/__init__.py::JSONSymbolTestCase::test_symbol_decoder", "tests/__init__.py::JSONSymbolTestCase::test_symbol_encoder", "tests/__init__.py::JSONPredicateTestCase::test_factbase_coder", "tests/__init__.py::JSONPredicateTestCase::test_predicate_coder", "tests/__init__.py::LibDateTestCase::test_datefield", "tests/__init__.py::LibDateTestCase::test_dates", "tests/__init__.py::LibDateTestCase::test_docstrings", "tests/__init__.py::LibDateTestCase::test_enumdate", "tests/__init__.py::LibDateTestCase::test_enumdates", "tests/__init__.py::LibTimeSlotTimeFieldTestCase::test_timefield", "tests/__init__.py::LibTimeSlotGranularityTestCase::test_granularity_15min", "tests/__init__.py::LibTimeSlotGranularityTestCase::test_granularity_75min", "tests/__init__.py::LibTimeSlotGranularityTestCase::test_granularity_bad", "tests/__init__.py::LibTimeSlotTestCase::test_round_ceil_and_floor", "tests/__init__.py::LibTimeSlotTestCase::test_timeslotrange_init", "tests/__init__.py::ClingoPatchTestCase::test_monkey", "tests/__init__.py::TypeCastSignatureTestCase::test_get_annotations_errors", "tests/__init__.py::TypeCastSignatureTestCase::test_input_signature", "tests/__init__.py::TypeCastSignatureTestCase::test_make_function_asp_callable", "tests/__init__.py::TypeCastSignatureTestCase::test_make_function_asp_callable_error_feedback", "tests/__init__.py::TypeCastSignatureTestCase::test_make_function_asp_callable_with_tuples", "tests/__init__.py::TypeCastSignatureTestCase::test_make_method_asp_callable_error_feedback", "tests/__init__.py::TypeCastSignatureTestCase::test_signature", "tests/__init__.py::TypeCastSignatureTestCase::test_signature_with_tuples", "tests/__init__.py::ContextBuilderTestCase::test_register", "tests/__init__.py::ContextBuilderTestCase::test_register_name", "tests/__init__.py::FieldTestCase::test_api_basefield_bad_instantiation", "tests/__init__.py::FieldTestCase::test_api_catch_bad_field_instantiation", "tests/__init__.py::FieldTestCase::test_api_clingo_pytocl_and_cltopy", "tests/__init__.py::FieldTestCase::test_api_combine_fields", "tests/__init__.py::FieldTestCase::test_api_define_enum_field", "tests/__init__.py::FieldTestCase::test_api_field_defaults", "tests/__init__.py::FieldTestCase::test_api_field_function", "tests/__init__.py::FieldTestCase::test_api_field_function_illegal_arguments", "tests/__init__.py::FieldTestCase::test_api_field_index", "tests/__init__.py::FieldTestCase::test_api_flat_list_field", "tests/__init__.py::FieldTestCase::test_api_nested_list_field", "tests/__init__.py::FieldTestCase::test_api_nested_list_field_alt", "tests/__init__.py::FieldTestCase::test_api_noclingo_pytocl_and_cltopy", "tests/__init__.py::FieldTestCase::test_api_primitive_field_conversion", "tests/__init__.py::FieldTestCase::test_api_raw_class", "tests/__init__.py::FieldTestCase::test_api_raw_pickling", "tests/__init__.py::FieldTestCase::test_api_refine_field_by_functor", "tests/__init__.py::FieldTestCase::test_api_refine_field_by_values", "tests/__init__.py::FieldTestCase::test_api_simplefield", "tests/__init__.py::FieldTestCase::test_api_user_defined_subclass", "tests/__init__.py::FieldTestCase::test_instantiate_BaseField", "tests/__init__.py::FieldTestCase::test_nonapi_combine_fields", "tests/__init__.py::PredicateTestCase::test_anon_nonlogicalsymbol", "tests/__init__.py::PredicateTestCase::test_api_subfield_access", "tests/__init__.py::PredicateTestCase::test_arity_len_nonlogicalsymbol", "tests/__init__.py::PredicateTestCase::test_bad_predicate_defn", "tests/__init__.py::PredicateTestCase::test_bad_predicate_instantiation", "tests/__init__.py::PredicateTestCase::test_complex_term_field_tuple_pytocl", "tests/__init__.py::PredicateTestCase::test_field_complex_class_property", "tests/__init__.py::PredicateTestCase::test_get_field_definition", "tests/__init__.py::PredicateTestCase::test_iter_bool_nonlogicalsymbol", "tests/__init__.py::PredicateTestCase::test_predicate_annotated_fields_union_StrictBool_int", "tests/__init__.py::PredicateTestCase::test_predicate_annotated_fields_union_bool_int", "tests/__init__.py::PredicateTestCase::test_predicate_anonymous_field_with_default", "tests/__init__.py::PredicateTestCase::test_predicate_cant_infer_field_from_annotation", "tests/__init__.py::PredicateTestCase::test_predicate_default_predicate_names", "tests/__init__.py::PredicateTestCase::test_predicate_defn_containing_indexed_fields", "tests/__init__.py::PredicateTestCase::test_predicate_kwargs_meta", "tests/__init__.py::PredicateTestCase::test_predicate_meta_kwargs_class_conflict", "tests/__init__.py::PredicateTestCase::test_predicate_with_default_field", "tests/__init__.py::PredicateTestCase::test_predicate_with_multi_field", "tests/__init__.py::PredicateTestCase::test_predicate_with_nested_list_field", "tests/__init__.py::PredicateTestCase::test_predicate_with_tuple_comparison", "tests/__init__.py::PredicateTestCase::test_predicate_with_wrong_mixed_annotations_and_Fields", "tests/__init__.py::PredicateTestCase::test_predicates_with_annotated_fields", "tests/__init__.py::PredicateTestCase::test_simple_predicate_defn", "tests/__init__.py::PredicateTestCase::test_subclassing_nonlogicalsymbol", "tests/__init__.py::PredicateTestCase::test_tuple_nonlogicalsymbol", "tests/__init__.py::FactPicklingTestCase::test_basic_predicate_pickling", "tests/__init__.py::FactPicklingTestCase::test_complex_predicate_pickling_global", "tests/__init__.py::PredicateInternalUnifyTestCase::test_clone", "tests/__init__.py::PredicateInternalUnifyTestCase::test_comparison_operator_overloads_complex", "tests/__init__.py::PredicateInternalUnifyTestCase::test_complex_predicate_defn", "tests/__init__.py::PredicateInternalUnifyTestCase::test_predicate_comparison_operator_overload_signed", "tests/__init__.py::PredicateInternalUnifyTestCase::test_predicate_comparison_operator_overloads", "tests/__init__.py::PredicateInternalUnifyTestCase::test_predicate_init_basic", "tests/__init__.py::PredicateInternalUnifyTestCase::test_predicate_init_named", "tests/__init__.py::PredicateInternalUnifyTestCase::test_predicate_init_neg_literals_signed_predicates", "tests/__init__.py::PredicateInternalUnifyTestCase::test_predicate_init_neg_literals_simple", "tests/__init__.py::PredicateInternalUnifyTestCase::test_predicate_init_positional", "tests/__init__.py::PredicateInternalUnifyTestCase::test_predicate_iterable", "tests/__init__.py::PredicateInternalUnifyTestCase::test_predicate_positional_access", "tests/__init__.py::PredicateInternalUnifyTestCase::test_predicate_value_by_index", "tests/__init__.py::PredicateInternalUnifyTestCase::test_predicate_with_function_default", "tests/__init__.py::PredicateInternalUnifyTestCase::test_simple_predicate_function", "tests/__init__.py::PredicateInternalUnifyTestCase::test_unifying_symbol_and_complex_predicate", "tests/__init__.py::PredicateInternalUnifyTestCase::test_unifying_symbol_and_predicate", "tests/__init__.py::PredicateInternalUnifyTestCase::test_using_slots_for_predicates", "tests/__init__.py::PredicatePathTestCase::test_api_comparison_operator_overloads", "tests/__init__.py::PredicatePathTestCase::test_api_path_and_hashable_path_bad_inputs", "tests/__init__.py::PredicatePathTestCase::test_api_path_and_hashable_path_inputs", "tests/__init__.py::PredicatePathTestCase::test_api_path_instance", "tests/__init__.py::PredicatePathTestCase::test_api_predicate_path_alias", "tests/__init__.py::PredicatePathTestCase::test_dealised_path_none", "tests/__init__.py::PredicatePathTestCase::test_dealised_path_predicate", "tests/__init__.py::PredicatePathTestCase::test_dealised_path_predicate_path", "tests/__init__.py::PredicatePathTestCase::test_dealised_raise_type_error", "tests/__init__.py::PredicatePathTestCase::test_nonapi_path_class", "tests/__init__.py::PredicatePathTestCase::test_nonapi_predicate_path_root", "tests/__init__.py::PredicatePathTestCase::test_resolve_fact_wrt_path", "tests/__init__.py::QConditionTestCase::test_api_boolean_operator_overloads", "tests/__init__.py::QConditionTestCase::test_api_formatting", "tests/__init__.py::QConditionTestCase::test_api_misc_functions", "tests/__init__.py::QConditionTestCase::test_nonapi_args_and_operator_access", "tests/__init__.py::QConditionTestCase::test_nonapi_explicit_and_implicit_creation", "tests/__init__.py::QConditionTestCase::test_nonapi_qcondition_creation", "tests/__init__.py::FactBaseTestCase::test_comparison_ops", "tests/__init__.py::FactBaseTestCase::test_container_ops", "tests/__init__.py::FactBaseTestCase::test_delayed_init", "tests/__init__.py::FactBaseTestCase::test_equality_fb_different_order", "tests/__init__.py::FactBaseTestCase::test_factbase_aspstr_signature", "tests/__init__.py::FactBaseTestCase::test_factbase_aspstr_sorted", "tests/__init__.py::FactBaseTestCase::test_factbase_aspstr_width", "tests/__init__.py::FactBaseTestCase::test_factbase_copy", "tests/__init__.py::FactBaseTestCase::test_factbase_iteration", "tests/__init__.py::FactBaseTestCase::test_factbase_normal_init", "tests/__init__.py::FactBaseTestCase::test_set_comparison_ops", "tests/__init__.py::FactBaseTestCase::test_set_ops", "tests/__init__.py::QueryAPI1TestCase::test_api_factbase_select_complex_term_placeholders", "tests/__init__.py::QueryAPI1TestCase::test_api_factbase_select_indexing", "tests/__init__.py::QueryAPI1TestCase::test_api_factbase_select_multi_placeholder", "tests/__init__.py::QueryAPI1TestCase::test_api_factbase_select_order_by", "tests/__init__.py::QueryAPI1TestCase::test_api_factbase_select_order_by_complex_term", "tests/__init__.py::QueryAPI1TestCase::test_api_factbase_select_placeholders_with_lambda", "tests/__init__.py::QueryAPI1TestCase::test_api_select_additional", "tests/__init__.py::QueryAPI1TestCase::test_api_select_factbase2", "tests/__init__.py::QueryAPI1TestCase::test_bad_factbase_select_delete_statements", "tests/__init__.py::QueryAPI1TestCase::test_factbase_delete", "tests/__init__.py::QueryAPI1TestCase::test_factbase_select", "tests/__init__.py::QueryAPI1TestCase::test_factbase_select_complex_where", "tests/__init__.py::QueryAPI1TestCase::test_factbase_select_with_subfields", "tests/__init__.py::QueryAPI1TestCase::test_select_by_predicate", "tests/__init__.py::QueryAPI2TestCase::test_api_bad_join_statement", "tests/__init__.py::QueryAPI2TestCase::test_api_complex_query_join_order_output", "tests/__init__.py::QueryAPI2TestCase::test_api_complex_query_join_ordered", "tests/__init__.py::QueryAPI2TestCase::test_api_nonselect_single_table", "tests/__init__.py::QueryAPI2TestCase::test_api_select_multi_table", "tests/__init__.py::QueryAPI2TestCase::test_api_select_multi_table_functor_select", "tests/__init__.py::QueryAPI2TestCase::test_api_select_multi_table_functor_where", "tests/__init__.py::QueryAPI2TestCase::test_api_select_single_table", "tests/__init__.py::QueryAPI2TestCase::test_api_select_single_table_bad", "tests/__init__.py::SelectJoinTestCase::test_api_select_self_join", "tests/__init__.py::MembershipQueriesTestCase::test_basic_membership", "tests/__init__.py::MembershipQueriesTestCase::test_membership_subquery", "tests/__init__.py::FactBasePicklingTestCase::test_factbase_pickling", "tests/__init__.py::FactBasePicklingTestCase::test_pickle_anonTuple", "tests/__init__.py::FactBasePicklingTestCase::test_pickled_factbase_querying", "tests/__init__.py::FactIndexTestCase::test_add", "tests/__init__.py::FactIndexTestCase::test_clear", "tests/__init__.py::FactIndexTestCase::test_create", "tests/__init__.py::FactIndexTestCase::test_find", "tests/__init__.py::FactIndexTestCase::test_find_ordering", "tests/__init__.py::FactIndexTestCase::test_remove", "tests/__init__.py::FactIndexTestCase::test_subfields", "tests/__init__.py::FactMapTestCase::test_factmap_basics", "tests/__init__.py::FactMapTestCase::test_factmap_copy", "tests/__init__.py::FactMapTestCase::test_set_ops", "tests/__init__.py::NoClingoTestCase::test_clingo_to_noclingo", "tests/__init__.py::NoClingoTestCase::test_comparison_nosymbol_and_symbol", "tests/__init__.py::NoClingoTestCase::test_comparison_ops", "tests/__init__.py::NoClingoTestCase::test_function", "tests/__init__.py::NoClingoTestCase::test_hash_and_equality_comparison_ops", "tests/__init__.py::NoClingoTestCase::test_infimum_supremum", "tests/__init__.py::NoClingoTestCase::test_invalid_values", "tests/__init__.py::NoClingoTestCase::test_number", "tests/__init__.py::NoClingoTestCase::test_same_error_messages", "tests/__init__.py::NoClingoTestCase::test_string", "tests/__init__.py::NoClingoTestCase::test_symbol_modes", "tests/__init__.py::NoClingoTestCase::test_tuple", "tests/__init__.py::NoClingoDisabledTestCase::test_noclingo_switch_disabled", "tests/__init__.py::PlaceholderTestCase::test_NamedPlaceholder", "tests/__init__.py::PlaceholderTestCase::test_PositionalPlaceholder", "tests/__init__.py::PlaceholderTestCase::test_placeholder_instantiation", "tests/__init__.py::QQConditionTestCase::test_complex_comparison_conditional", "tests/__init__.py::QQConditionTestCase::test_nonapi_not_bool_not_comparison_condition", "tests/__init__.py::QQConditionTestCase::test_simple_comparison_conditional", "tests/__init__.py::ComparatorTestCase::test_api_func", "tests/__init__.py::ComparatorTestCase::test_nonapi_FunctionComparator", "tests/__init__.py::ComparatorTestCase::test_nonapi_FunctionComparator_with_args", "tests/__init__.py::ComparatorTestCase::test_nonapi_StandardComparator", "tests/__init__.py::ComparatorTestCase::test_nonapi_StandardComparator_keyable", "tests/__init__.py::ComparatorTestCase::test_nonapi_StandardComparator_make_callable_with_tuples", "tests/__init__.py::ComparatorTestCase::test_nonapi_comparison_callables", "tests/__init__.py::ComparatorTestCase::test_nonapi_make_input_alignment_functor", "tests/__init__.py::ComparatorTestCase::test_nonapi_make_input_alignment_functor_complex", "tests/__init__.py::WhereExpressionTestCase::test_nonapi_Clause", "tests/__init__.py::WhereExpressionTestCase::test_nonapi_ClauseBlock", "tests/__init__.py::WhereExpressionTestCase::test_nonapi_negate_where_expression", "tests/__init__.py::WhereExpressionTestCase::test_nonapi_normalise_where_expression", "tests/__init__.py::WhereExpressionTestCase::test_nonapi_partition_clauses", "tests/__init__.py::WhereExpressionTestCase::test_nonapi_validate_where_expression", "tests/__init__.py::WhereExpressionTestCase::test_nonapi_where_expression_to_cnf", "tests/__init__.py::WhereExpressionTestCase::test_nonapi_where_expression_to_nnf", "tests/__init__.py::JoinExpressionTestCase::test_nonapi_validate_join_expression", "tests/__init__.py::OrderByTestCase::test_api_asc_desc", "tests/__init__.py::OrderByTestCase::test_nonapi_OrderByBlock", "tests/__init__.py::OrderByTestCase::test_nonapi_OrderBy_1d", "tests/__init__.py::OrderByTestCase::test_nonapi_validate_orderby_expression", "tests/__init__.py::QueryPlanTestCase::test_make_query_plan", "tests/__init__.py::QueryPlanTestCase::test_make_query_plan_membership", "tests/__init__.py::QueryPlanTestCase::test_nonapi_JoinQueryPlan", "tests/__init__.py::QueryPlanTestCase::test_nonapi_JoinQueryPlan_with_complex_prejoin_key_clause", "tests/__init__.py::QueryPlanTestCase::test_nonapi_QueryPlan", "tests/__init__.py::QueryPlanTestCase::test_nonapi_basic_join_order", "tests/__init__.py::QueryPlanTestCase::test_nonapi_fixed_join_order", "tests/__init__.py::QueryPlanTestCase::test_nonapi_make_join_pair", "tests/__init__.py::QueryPlanTestCase::test_nonapi_make_prejoin_pair", "tests/__init__.py::QueryPlanTestCase::test_nonapi_make_prejoin_pair_simple", "tests/__init__.py::QueryPlanTestCase::test_nonapi_make_query_plan_preordered_roots", "tests/__init__.py::QueryPlanTestCase::test_nonapi_oppref_join_order", "tests/__init__.py::QueryPlanTestCase::test_nonapi_partition_orderbys", "tests/__init__.py::InQuerySorterTestCase::test_InQuerySorter_bad", "tests/__init__.py::InQuerySorterTestCase::test_InQuerySorter_facttuples", "tests/__init__.py::InQuerySorterTestCase::test_InQuerySorter_singlefacts", "tests/__init__.py::QueryTestCase::test_make_first_join_query", "tests/__init__.py::QueryTestCase::test_make_first_prejoin_query", "tests/__init__.py::QueryTestCase::test_make_query", "tests/__init__.py::QueryTestCase::test_nonapi_make_chained_join_query", "tests/__init__.py::QueryTestCase::test_nonapi_make_prejoin_query_source", "tests/__init__.py::QueryTestCase::test_nonapi_make_query_sort_order", "tests/__init__.py::QueryExecutorTestCase::test_api_QueryExecutor_delete", "tests/__init__.py::QueryExecutorTestCase::test_api_QueryExecutor_delete_nowhere_clause", "tests/__init__.py::QueryExecutorTestCase::test_api_QueryExecutor_modify", "tests/__init__.py::QueryExecutorTestCase::test_api_QueryExecutor_output_alignment", "tests/__init__.py::QueryExecutorTestCase::test_api_QueryExecutor_replace", "tests/__init__.py::QueryExecutorTestCase::test_nonapi_QueryExecutor", "tests/__init__.py::QueryExecutorTestCase::test_nonapi_QueryExecutor_contains", "tests/__init__.py::QueryExecutorTestCase::test_nonapi_QueryExecutor_contains_indexed", "tests/__init__.py::QueryExecutorTestCase::test_nonapi_QueryExecutor_order", "tests/__init__.py::QueryExecutorTestCase::test_nonapi_QueryExecutor_sort_order", "tests/__init__.py::QueryExecutorTestCase::test_nonapi_basic_tests", "tests/__init__.py::QueryExecutorTestCase::test_nonapi_default_output_spec", "tests/__init__.py::QueryExecutorTestCase::test_nonapi_group_by", "tests/__init__.py::QueryExecutorTestCase::test_nonapi_inequality_join_tests", "tests/__init__.py::UnifyTestCase::test_predicate_instance_raw_term", "tests/__init__.py::UnifyTestCase::test_symbolpredicateunifier", "tests/__init__.py::UnifyTestCase::test_symbolpredicateunifier_symbols", "tests/__init__.py::UnifyTestCase::test_symbolpredicateunifier_with_subfields", "tests/__init__.py::UnifyTestCase::test_unify", "tests/__init__.py::UnifyTestCase::test_unify_catch_exceptions", "tests/__init__.py::UnifyTestCase::test_unify_nullary", "tests/__init__.py::UnifyTestCase::test_unify_same_sig", "tests/__init__.py::UnifyTestCase::test_unify_same_sig2", "tests/__init__.py::UnifyTestCase::test_unify_signed_literals", "tests/__init__.py::ClingoControlConvTestCase::test_control_add_facts", "tests/__init__.py::ClingoControlConvTestCase::test_symbolic_atoms_to_facts", "tests/__init__.py::ParseTestCase::test_lark_parse_facts", "tests/__init__.py::ParseTestCase::test_lark_parse_nested_facts", "tests/__init__.py::ParseTestCase::test_lark_parse_non_simple_facts", "tests/__init__.py::ParseTestCase::test_parse_facts", "tests/__init__.py::ParseTestCase::test_parse_nested_facts", "tests/__init__.py::ParseTestCase::test_parse_non_simple_facts", "tests/__init__.py::OrderedSetTestCase::test_basic_creation_iteration", "tests/__init__.py::OrderedSetTestCase::test_basic_ops", "tests/__init__.py::OrderedSetTestCase::test_bool_len_contains", "tests/__init__.py::OrderedSetTestCase::test_bool_ops", "tests/__init__.py::OrderedSetTestCase::test_copy_equality", "tests/__init__.py::OrderedSetTestCase::test_set_union_intersection_functions", "tests/__init__.py::OrderedSetTestCase::test_set_union_intersection_operators", "tests/__init__.py::OrderedSetTestCase::test_str_repr", "tests/__init__.py::OrderedSetTestCase::test_update_set_union_intersection_functions", "tests/__init__.py::ToolsTestCase::test_nonapi_all_equal", "tests/__init__.py::WrapperMetaClassTestCase::test_bad_wrapper", "tests/__init__.py::WrapperMetaClassTestCase::test_simple_wrapper", "tests/__init__.py::WrapperMetaClassTestCase::test_wrapper_diff_type", "tests/__init__.py::WrapperMetaClassTestCase::test_wrapper_of_wrapper", "tests/__init__.py::WrapperMetaClassTestCase::test_wrapper_with_overrides", "tests/__init__.py::WrapperFunctionTestCase::test_bad_wrapper", "tests/__init__.py::WrapperFunctionTestCase::test_simple_wrapper", "tests/__init__.py::WrapperFunctionTestCase::test_wrapper_diff_type", "tests/__init__.py::WrapperFunctionTestCase::test_wrapper_of_wrapper", "tests/__init__.py::WrapperFunctionTestCase::test_wrapper_with_overrides" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2024-02-10 11:40:02+00:00
mit
4,637
ppannuto__python-titlecase-60
diff --git a/titlecase/__init__.py b/titlecase/__init__.py index 8ee158f..050b6c5 100755 --- a/titlecase/__init__.py +++ b/titlecase/__init__.py @@ -62,28 +62,7 @@ def set_small_word_list(small=SMALL): SUBPHRASE = regex.compile(r'([:.;?!][ ])(%s)' % small) -def create_wordlist_filter(path_to_config=None): - """ - This function checks for a default list of abbreviations which need to - remain as they are (e.g. uppercase only or mixed case). - The file is retrieved from ~/.titlecase.txt (platform independent) - """ - if path_to_config is None: - path_to_config = os.path.join(os.path.expanduser('~'), ".titlecase.txt") - if not os.path.isfile(str(path_to_config)): - logger.debug('No config file found at ' + str(path_to_config)) - return lambda word, **kwargs : None - with open(str(path_to_config)) as f: - logger.debug('Config file used from ' + str(path_to_config)) - abbreviations = [abbr.strip() for abbr in f.read().splitlines() if abbr] - abbreviations_capitalized = [abbr.upper() for abbr in abbreviations] - for abbr in abbreviations: - logger.debug("This acronym will be kept as written here: " + abbr) - return lambda word, **kwargs : (abbreviations[abbreviations_capitalized.index(word.upper())] - if word.upper() in abbreviations_capitalized else None) - - -def titlecase(text, callback=None, small_first_last=True, wordlist_file=None): +def titlecase(text, callback=None, small_first_last=True): """ :param text: Titlecases input text :param callback: Callback function that returns the titlecase version of a specific word @@ -99,8 +78,6 @@ def titlecase(text, callback=None, small_first_last=True, wordlist_file=None): the New York Times Manual of Style, plus 'vs' and 'v'. """ - wordlist_filter = create_wordlist_filter(wordlist_file) - lines = regex.split('[\r\n]+', text) processed = [] for line in lines: @@ -116,12 +93,6 @@ def titlecase(text, callback=None, small_first_last=True, wordlist_file=None): tc_line.append(_mark_immutable(new_word)) continue - # If the user has a custom wordlist, defer to that - new_word = wordlist_filter(word, all_caps=all_caps) - if new_word: - tc_line.append(_mark_immutable(new_word)) - continue - if all_caps: if UC_INITIALS.match(word): tc_line.append(word) @@ -207,6 +178,30 @@ def titlecase(text, callback=None, small_first_last=True, wordlist_file=None): return result +def create_wordlist_filter_from_file(file_path): + ''' + Load a list of abbreviations from the file with the provided path, + reading one abbreviation from each line, and return a callback to + be passed to the `titlecase` function for preserving their given + canonical capitalization during title-casing. + ''' + if file_path is None: + logger.debug('No abbreviations file path given') + return lambda word, **kwargs: None + file_path_str = str(file_path) + if not os.path.isfile(file_path_str): + logger.debug('No abbreviations file found at ' + file_path_str) + return lambda word, **kwargs: None + with open(file_path_str) as f: + logger.debug('Reading abbreviations from file ' + file_path_str) + abbrevs_gen = (line.strip() for line in f.read().splitlines() if line) + abbrevs = {abbr.upper(): abbr for abbr in abbrevs_gen} + if logger.isEnabledFor(logging.DEBUG): + for abbr in abbrevs.values(): + logger.debug('Registered abbreviation: ' + abbr) + return lambda word, **kwargs: abbrevs.get(word.upper()) + + def cmd(): '''Handler for command line invocation''' @@ -249,5 +244,11 @@ def cmd(): with ifile: in_string = ifile.read() + if args.wordlist is not None: + wordlist_file = args.wordlist + else: + wordlist_file = os.path.join(os.path.expanduser('~'), '.titlecase.txt') + wordlist_filter = create_wordlist_filter_from_file(wordlist_file) + with ofile: - ofile.write(titlecase(in_string, wordlist_file=args.wordlist)) + ofile.write(titlecase(in_string, callback=wordlist_filter))
ppannuto/python-titlecase
899d425f1b5ddac89afb1fc18d3c95f6197484bf
diff --git a/titlecase/tests.py b/titlecase/tests.py index 0b3aad1..e57e4f8 100644 --- a/titlecase/tests.py +++ b/titlecase/tests.py @@ -10,7 +10,7 @@ import sys import tempfile sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../')) -from titlecase import titlecase, set_small_word_list +from titlecase import titlecase, set_small_word_list, create_wordlist_filter_from_file # (executed by `test_input_output` below) @@ -363,7 +363,7 @@ def test_custom_abbreviations(): # Without a wordlist, this will do the "wrong" thing for the context assert titlecase('SENDING UDP PACKETS OVER PPPOE WORKS GREAT') == 'Sending Udp Packets Over Pppoe Works Great' # A wordlist can provide custom acronyms - assert titlecase('sending UDP packets over PPPoE works great', wordlist_file=f.name) == 'Sending UDP Packets Over PPPoE Works Great' + assert titlecase('sending UDP packets over PPPoE works great', callback=create_wordlist_filter_from_file(f.name)) == 'Sending UDP Packets Over PPPoE Works Great' if __name__ == "__main__":
It is impossible to prevent titlecase() from reading the ‘~/.titlecase.txt’ file It makes sense to have that behavior as default for the `titlecase` *command* (especially when it is invoked directly by the user from the command line), but not for the `titlecase()` *function* that may be called from some library code, which should not be accessing the file system at all! Besides, when writing a script using `titlecase()`, one often needs to have a way to ensure consistent results across all users’ machines, regardless of what each particular user has in their `~/.titlecase.txt` file (and whether they have the file at all). Also, as for libraries, for some scripts it may not even be appropriate (nor allowed) to access the user’s file system. I propose to change the behavior of the `titlecase()` function to, at the very least, not attempt reading `~/.titlecase.txt` (or any other files, for that matter) when its `wordlist_file` argument has the value of `None`. In general, unless an effort is made by the caller, the call to `titlecase()` should *not* incur any filesystem operations. I have made the minimal required fix for that in #59.
0.0
899d425f1b5ddac89afb1fc18d3c95f6197484bf
[ "titlecase/tests.py::test_initials_regex", "titlecase/tests.py::test_initials_regex_2", "titlecase/tests.py::test_initials_regex_3", "titlecase/tests.py::test_at_and_t", "titlecase/tests.py::test_callback", "titlecase/tests.py::test_set_small_word_list", "titlecase/tests.py::test_custom_abbreviations" ]
[]
{ "failed_lite_validators": [ "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2020-06-12 19:15:08+00:00
mit
4,638
ppannuto__python-titlecase-63
diff --git a/titlecase/__init__.py b/titlecase/__init__.py index 050b6c5..65341c3 100755 --- a/titlecase/__init__.py +++ b/titlecase/__init__.py @@ -129,7 +129,7 @@ def titlecase(text, callback=None, small_first_last=True): if '-' in word: hyphenated = map( - lambda t: titlecase(t, callback, small_first_last), + lambda t: titlecase(t, callback, False), word.split('-') ) tc_line.append("-".join(hyphenated))
ppannuto/python-titlecase
c2651eea4ea0a66b3ffda7c006e45b3e26026b9a
diff --git a/titlecase/tests.py b/titlecase/tests.py index e57e4f8..bfacf9d 100644 --- a/titlecase/tests.py +++ b/titlecase/tests.py @@ -31,6 +31,10 @@ TEST_DATA = ( "dance with me/let’s face the music and dance", "Dance With Me/Let’s Face the Music and Dance" ), + ( + "a-b end-to-end two-not-three/three-by-four/five-and", + "A-B End-to-End Two-Not-Three/Three-by-Four/Five-And" + ), ( "34th 3rd 2nd", "34th 3rd 2nd"
Small words are erroneously capitalized within hyphenated compound words When `titlecase()` recurses to process separate words of a hyphenated compound word, it passes on the current value of the `small_first_last` parameter unchanged. Naturally, this leads to incorrect title-casing of compound words, containing small words. For instance, words `end-to-end` and `work-in-progress` are currently title-cased as `End-To-End` and `Work-In-Progress` instead of the correct `End-to-End` and `Work-in-Progress`.
0.0
c2651eea4ea0a66b3ffda7c006e45b3e26026b9a
[ "titlecase/tests.py::test_callback" ]
[ "titlecase/tests.py::test_initials_regex", "titlecase/tests.py::test_initials_regex_3", "titlecase/tests.py::test_at_and_t", "titlecase/tests.py::test_initials_regex_2", "titlecase/tests.py::test_custom_abbreviations", "titlecase/tests.py::test_set_small_word_list" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2020-06-15 16:42:01+00:00
mit
4,639
ppizarror__pygame-menu-324
diff --git a/pygame_menu/_widgetmanager.py b/pygame_menu/_widgetmanager.py index 28af48e8..c962106b 100644 --- a/pygame_menu/_widgetmanager.py +++ b/pygame_menu/_widgetmanager.py @@ -235,6 +235,8 @@ class WidgetManager(Base): else: selection_effect = selection_effect.copy() assert isinstance(selection_effect, pygame_menu.widgets.core.Selection) + + selection_effect.set_color(attributes['selection_color']) attributes['selection_effect'] = selection_effect # tab_size diff --git a/pygame_menu/themes.py b/pygame_menu/themes.py index e5069ed9..b084af95 100644 --- a/pygame_menu/themes.py +++ b/pygame_menu/themes.py @@ -137,7 +137,7 @@ class Theme(object): :type scrollbar_slider_pad: int, float :param scrollbar_thick: Scrollbar thickness in px :type scrollbar_thick: int - :param selection_color: Color of the selected widget + :param selection_color: Color of the selected widget. It updates both selected font and ``widget_selection_effect`` color :type selection_color: tuple, list, str, int, :py:class:`pygame.Color` :param surface_clear_color: Surface clear color before applying background function :type surface_clear_color: tuple, list, str, int, :py:class:`pygame.Color` @@ -376,10 +376,6 @@ class Theme(object): self.scrollbar_thick = self._get(kwargs, 'scrollbar_thick', int, 20) # Generic widget themes - default_selection_effect = HighlightSelection(margin_x=0, margin_y=0).set_color(self.selection_color) - self.widget_selection_effect = self._get(kwargs, 'widget_selection_effect', Selection, - default_selection_effect) - self.widget_alignment = self._get(kwargs, 'widget_alignment', 'alignment', ALIGN_CENTER) self.widget_background_color = self._get(kwargs, 'widget_background_color', 'color_image_none') self.widget_background_inflate = self._get(kwargs, 'background_inflate', 'tuple2int', (0, 0)) @@ -412,6 +408,8 @@ class Theme(object): self.widget_margin = self._get(kwargs, 'widget_margin', 'tuple2', (0, 0)) self.widget_offset = self._get(kwargs, 'widget_offset', 'tuple2', (0, 0)) self.widget_padding = self._get(kwargs, 'widget_padding', PaddingInstance, (4, 8)) + self.widget_selection_effect = self._get(kwargs, 'widget_selection_effect', Selection, + HighlightSelection(margin_x=0, margin_y=0)) self.widget_tab_size = self._get(kwargs, 'widget_tab_size', int, 4) self.widget_url_color = self._get(kwargs, 'widget_url_color', 'color', (6, 69, 173)) @@ -618,6 +616,7 @@ class Theme(object): :return: Copied theme """ + self.validate() return copy.deepcopy(self) def __copy__(self) -> 'Theme': diff --git a/pygame_menu/version.py b/pygame_menu/version.py index 61f92826..c6d43cb1 100644 --- a/pygame_menu/version.py +++ b/pygame_menu/version.py @@ -57,6 +57,6 @@ class Version(tuple): patch = property(lambda self: self[2]) -vernum = Version(4, 0, 3) +vernum = Version(4, 0, 4) ver = str(vernum) rev = ''
ppizarror/pygame-menu
867ed8afdf60f787ea8b0dc22d8b55bb5f636175
diff --git a/test/test_themes.py b/test/test_themes.py index a3f5f5e0..72d8ebed 100644 --- a/test/test_themes.py +++ b/test/test_themes.py @@ -31,6 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. __all__ = ['ThemeTest'] +from test._utils import MenuUtils from pathlib import Path import unittest @@ -90,6 +91,23 @@ class ThemeTest(unittest.TestCase): self.assertEqual(theme_white.selection_color, color_main) self.assertEqual(sub_theme_white.selection_color, color_copy) + self.assertNotEqual(theme_white.selection_color, sub_theme_white.selection_color) + self.assertNotEqual(theme_white.widget_selection_effect, sub_theme_white.widget_selection_effect) + + # Test the widget effect color is different in both objects + m1 = MenuUtils.generic_menu(theme=theme_white) + m2 = MenuUtils.generic_menu(theme=sub_theme_white) + b1 = m1.add.button('1') + b2 = m2.add.button('2') + + self.assertEqual(b1._selection_effect.color, b1.get_menu().get_theme().selection_color) + self.assertEqual(b2._selection_effect.color, b2.get_menu().get_theme().selection_color) + self.assertNotEqual(b1._selection_effect.color, b2._selection_effect.color) + + # Main Theme selection effect class should not be modified + self.assertEqual(b1.get_menu().get_theme(), theme_white) + self.assertEqual(theme_white.widget_selection_effect.color, (0, 0, 0)) + def test_methods(self) -> None: """ Test theme method.
Copy theme and modify attributes **Environment information** Describe your environment information, such as: - SO: OSX - python version: v3.7.7 - pygame version: v2.0.1 - pygame-menu version: v4.0.2 **Describe the bug** Creating theme by copy, then modifying `selection_color` is not taken into account. **To Reproduce** ``` THEME_WHITE = pgm.themes.Theme( background_color=(255, 255, 255), scrollbar_thick=14, scrollbar_slider_pad=2, scrollbar_slider_color=(35, 149, 135), selection_color=(29, 120, 107), title_background_color=(35, 149, 135), title_font=fonts.get_filename("Monoid-Regular"), title_font_size=33, title_font_color=(255, 255, 255), widget_margin=(0, 20), widget_font=fonts.get_filename("Monoid-Retina"), widget_font_size=30, widget_font_color=(0, 0, 0), ) SUBTHEME1_WHITE = THEME_WHITE.copy() SUBTHEME1_WHITE.background_color = (255, 255, 255) SUBTHEME1_WHITE.scrollbar_slider_color = (252, 151, 0) SUBTHEME1_WHITE.selection_color = (241, 125, 1) SUBTHEME1_WHITE.title_background_color = (252, 151, 0) SUBTHEME1_WHITE.widget_alignment = pgm.locals.ALIGN_LEFT SUBTHEME1_WHITE.widget_margin = (40, 10) SUBTHEME1_WHITE.widget_font_size = 18 ``` **Expected behavior** Menu using the theme SUBTHEME1_WHITE should have selection color of (241, 125, 1), but have (29, 120, 107)
0.0
867ed8afdf60f787ea8b0dc22d8b55bb5f636175
[ "test/test_themes.py::ThemeTest::test_copy" ]
[ "test/test_themes.py::ThemeTest::test_format_opacity", "test/test_themes.py::ThemeTest::test_get", "test/test_themes.py::ThemeTest::test_invalid_kwargs", "test/test_themes.py::ThemeTest::test_methods", "test/test_themes.py::ThemeTest::test_str_int_color", "test/test_themes.py::ThemeTest::test_to_tuple", "test/test_themes.py::ThemeTest::test_validation" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2021-04-27 18:12:49+00:00
mit
4,640
ppizarror__pygame-menu-334
diff --git a/.gitignore b/.gitignore index a58858dd..71921c80 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,7 @@ pyproject_update.py pyproject.toml # Lock file -*.lock \ No newline at end of file +*.lock + +# MacOS files +.DS_Store \ No newline at end of file diff --git a/pygame_menu/utils.py b/pygame_menu/utils.py index 2987c672..d4075062 100644 --- a/pygame_menu/utils.py +++ b/pygame_menu/utils.py @@ -43,6 +43,7 @@ __all__ = [ 'check_key_pressed_valid', 'fill_gradient', 'format_color', + 'get_cursor', 'get_finger_pos', 'is_callable', 'load_pygame_image_file', @@ -352,6 +353,19 @@ def format_color( return c.r, c.g, c.b, c.a +def get_cursor() -> CursorInputType: + """ + Returns the pygame cursor object. + + :return: Cursor object + """ + try: + return pygame.mouse.get_cursor() + except TypeError as e: + warn(str(e)) + return None + + def get_finger_pos(menu: 'pygame_menu.Menu', event: EventType) -> Tuple2IntType: """ Return the position from finger (or mouse) event on x-axis and y-axis (x, y). diff --git a/pygame_menu/widgets/core/widget.py b/pygame_menu/widgets/core/widget.py index d4ae8902..37aa23c6 100644 --- a/pygame_menu/widgets/core/widget.py +++ b/pygame_menu/widgets/core/widget.py @@ -65,7 +65,8 @@ from pygame_menu.locals import POSITION_NORTHWEST, POSITION_SOUTHWEST, POSITION_ from pygame_menu.sound import Sound from pygame_menu.utils import make_surface, assert_alignment, assert_color, \ assert_position, assert_vector, is_callable, parse_padding, uuid4, \ - mouse_motion_current_mouse_position, PYGAME_V2, set_pygame_cursor, warn + mouse_motion_current_mouse_position, PYGAME_V2, set_pygame_cursor, warn, \ + get_cursor from pygame_menu.widgets.core.selection import Selection from pygame_menu._types import Optional, ColorType, Tuple2IntType, NumberType, \ @@ -597,7 +598,7 @@ class Widget(Base): check_widget_mouseleave(event) # Change cursor - previous_cursor = pygame.mouse.get_cursor() # Previous cursor + previous_cursor = get_cursor() # Previous cursor set_pygame_cursor(self._cursor) # Update previous state
ppizarror/pygame-menu
9d231a56310b936c47f85bb80e2f331e8d85a137
diff --git a/test/test_base.py b/test/test_base.py index 3b10d1b5..7ef1c515 100644 --- a/test/test_base.py +++ b/test/test_base.py @@ -1,6 +1,6 @@ """ -pygame-obj -https://github.com/ppizarror/pygame-obj +pygame-menu +https://github.com/ppizarror/pygame-menu TEST BASE Test base class. diff --git a/test/test_controls.py b/test/test_controls.py index 371cef4a..ccd3c094 100644 --- a/test/test_controls.py +++ b/test/test_controls.py @@ -1,6 +1,6 @@ """ -pygame-obj -https://github.com/ppizarror/pygame-obj +pygame-menu +https://github.com/ppizarror/pygame-menu TEST CONTROLS Test controls configuration. diff --git a/test/test_frame.py b/test/test_frame.py index d58e6b1d..738d6c64 100644 --- a/test/test_frame.py +++ b/test/test_frame.py @@ -42,7 +42,7 @@ import pygame_menu import pygame_menu.controls as ctrl from pygame_menu.locals import ORIENTATION_VERTICAL, ORIENTATION_HORIZONTAL -from pygame_menu.utils import set_pygame_cursor +from pygame_menu.utils import set_pygame_cursor, get_cursor from pygame_menu.widgets import Button @@ -1504,11 +1504,13 @@ class FrameWidgetTest(unittest.TestCase): f3._id__repr__ = True # Get cursors - cur_none = pygame.mouse.get_cursor() + cur_none = get_cursor() + if cur_none is None: + return set_pygame_cursor(pygame_menu.locals.CURSOR_ARROW) - cur_arrow = pygame.mouse.get_cursor() + cur_arrow = get_cursor() set_pygame_cursor(pygame_menu.locals.CURSOR_HAND) - cur_hand = pygame.mouse.get_cursor() + cur_hand = get_cursor() set_pygame_cursor(cur_none) if PYGAME_V2: @@ -1628,92 +1630,92 @@ class FrameWidgetTest(unittest.TestCase): # | .---------------------. | # .-------------------------. # vbottom <100px> - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) menu.update(PygameEventUtils.topleft_rect_mouse_motion(f1)) self.assertEqual(test, [True, False, False, False, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [f1, [f1, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur_hand) + self.assertEqual(get_cursor(), cur_hand) # Move to b1 inside f1 menu.update(PygameEventUtils.topleft_rect_mouse_motion(b1)) self.assertEqual(test, [True, True, False, False, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [b1, [b1, cur_hand, [f1, cur_none, []]]]) - self.assertEqual(pygame.mouse.get_cursor(), cur_arrow) + self.assertEqual(get_cursor(), cur_arrow) # Move to f2, inside f1 menu.update(PygameEventUtils.topleft_rect_mouse_motion(f2)) self.assertEqual(test, [True, False, True, False, False, False]) # out from b1 self.assertEqual(WIDGET_MOUSEOVER, [f2, [f2, cur_hand, [f1, cur_none, []]]]) - self.assertEqual(pygame.mouse.get_cursor(), cur_hand) + self.assertEqual(get_cursor(), cur_hand) # Move to b2, inside f2+f1 menu.update(PygameEventUtils.topleft_rect_mouse_motion(b2)) self.assertEqual(test, [True, False, True, True, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [b2, [b2, cur_hand, [f2, cur_hand, [f1, cur_none, []]]]]) - self.assertEqual(pygame.mouse.get_cursor(), cur_arrow) + self.assertEqual(get_cursor(), cur_arrow) # Move to f3 menu.update(PygameEventUtils.topleft_rect_mouse_motion(f3)) self.assertEqual(test, [True, False, True, False, True, False]) # out from b2 self.assertEqual(WIDGET_MOUSEOVER, [f3, [f3, cur_hand, [f2, cur_hand, [f1, cur_none, []]]]]) - self.assertEqual(pygame.mouse.get_cursor(), cur_hand) + self.assertEqual(get_cursor(), cur_hand) # Move to b3, inside f3+f2+f1 menu.update(PygameEventUtils.topleft_rect_mouse_motion(b3)) self.assertEqual(test, [True, False, True, False, True, True]) self.assertEqual(WIDGET_MOUSEOVER, [b3, [b3, cur_hand, [f3, cur_hand, [f2, cur_hand, [f1, cur_none, []]]]]]) - self.assertEqual(pygame.mouse.get_cursor(), cur_arrow) + self.assertEqual(get_cursor(), cur_arrow) # From b3, move mouse out from window menu.update(PygameEventUtils.leave_window()) self.assertEqual(test, [False, False, False, False, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) # Move from out to inner widget (b3), this should call f1->f2->f3->b3 menu.update(PygameEventUtils.topleft_rect_mouse_motion(b3)) self.assertEqual(test, [True, False, True, False, True, True]) self.assertEqual(WIDGET_MOUSEOVER, [b3, [b3, cur_hand, [f3, cur_hand, [f2, cur_hand, [f1, cur_none, []]]]]]) - self.assertEqual(pygame.mouse.get_cursor(), cur_arrow) + self.assertEqual(get_cursor(), cur_arrow) # Move from b3->f2, this should call b3, f3 but not call f2 as this is actually over menu.update(PygameEventUtils.topleft_rect_mouse_motion(f2)) self.assertEqual(test, [True, False, True, False, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [f2, [f2, cur_hand, [f1, cur_none, []]]]) - self.assertEqual(pygame.mouse.get_cursor(), cur_hand) + self.assertEqual(get_cursor(), cur_hand) # Move from f2->b1, this should call f2 menu.update(PygameEventUtils.topleft_rect_mouse_motion(b1)) self.assertEqual(test, [True, True, False, False, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [b1, [b1, cur_hand, [f1, cur_none, []]]]) - self.assertEqual(pygame.mouse.get_cursor(), cur_arrow) + self.assertEqual(get_cursor(), cur_arrow) # Move from b1 to outside the menu menu.update(PygameEventUtils.topleft_rect_mouse_motion((1, 1))) self.assertEqual(test, [False, False, False, False, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) # Move from out to b2, this should call f1->f2->b2 menu.update(PygameEventUtils.topleft_rect_mouse_motion(b2)) self.assertEqual(test, [True, False, True, True, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [b2, [b2, cur_hand, [f2, cur_hand, [f1, cur_none, []]]]]) self.assertEqual(menu.get_mouseover_widget(), b2) - self.assertEqual(pygame.mouse.get_cursor(), cur_arrow) + self.assertEqual(get_cursor(), cur_arrow) # Unpack b2 f2.unpack(b2) if test != [False, False, False, False, False, False]: return self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) # Check b2 menu.scroll_to_widget(b2) menu.update(PygameEventUtils.topleft_rect_mouse_motion(b2)) self.assertEqual(test, [False, False, False, True, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [b2, [b2, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur_arrow) + self.assertEqual(get_cursor(), cur_arrow) def test_title(self) -> None: """ diff --git a/test/test_menu.py b/test/test_menu.py index ae35b385..e9d27ce8 100644 --- a/test/test_menu.py +++ b/test/test_menu.py @@ -46,7 +46,7 @@ import pygame_menu.controls as ctrl from pygame_menu import events from pygame_menu.locals import FINGERDOWN, FINGERMOTION -from pygame_menu.utils import set_pygame_cursor +from pygame_menu.utils import set_pygame_cursor, get_cursor from pygame_menu.widgets import Label, Button # Configure the tests @@ -1803,13 +1803,15 @@ class MenuTest(unittest.TestCase): self.assertEqual(WIDGET_MOUSEOVER, [None, []]) # Get cursors - cur_none = pygame.mouse.get_cursor() + cur_none = get_cursor() + if cur_none is None: + return set_pygame_cursor(btn1._cursor) - cur1 = pygame.mouse.get_cursor() + cur1 = get_cursor() set_pygame_cursor(btn2._cursor) - cur2 = pygame.mouse.get_cursor() + cur2 = get_cursor() set_pygame_cursor(cur_none) @@ -1823,31 +1825,31 @@ class MenuTest(unittest.TestCase): surface.fill((255, 255, 255), btn1.get_rect(to_real_position=True)) deco.add_callable(draw_rect, prev=False, pass_args=False) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) menu.update(PygameEventUtils.middle_rect_mouse_motion(btn1)) self.assertEqual(menu.get_selected_widget(), btn1) self.assertEqual(test, [True, False, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [btn1, [btn1, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur1) + self.assertEqual(get_cursor(), cur1) # Place mouse away. This should force widget 1 mouseleave mouse_away_event = PygameEventUtils.middle_rect_click((1000, 1000), evtype=pygame.MOUSEMOTION) menu.update(mouse_away_event) self.assertEqual(test, [True, True, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) # Place over widget 2 menu.update(PygameEventUtils.middle_rect_mouse_motion(btn2)) self.assertEqual(test, [True, True, True, False]) self.assertEqual(WIDGET_MOUSEOVER, [btn2, [btn2, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur2) + self.assertEqual(get_cursor(), cur2) # Place mouse away. This should force widget 1 mouseleave menu.update(mouse_away_event) self.assertEqual(test, [True, True, True, True]) self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) # Test immediate switch, from 1 to 2, then from 2 to 1, then off test = [False, False, False, False] @@ -1855,16 +1857,16 @@ class MenuTest(unittest.TestCase): self.assertEqual(menu.get_selected_widget(), btn1) self.assertEqual(test, [True, False, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [btn1, [btn1, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur1) + self.assertEqual(get_cursor(), cur1) menu.update(PygameEventUtils.middle_rect_mouse_motion(btn2)) self.assertEqual(menu.get_selected_widget(), btn1) self.assertEqual(test, [True, True, True, False]) self.assertEqual(WIDGET_MOUSEOVER, [btn2, [btn2, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur2) + self.assertEqual(get_cursor(), cur2) menu.update(mouse_away_event) self.assertEqual(test, [True, True, True, True]) self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) # Same switch test, but now with widget selection by mouse motion menu._mouse_motion_selection = True @@ -1875,20 +1877,20 @@ class MenuTest(unittest.TestCase): self.assertEqual(menu.get_selected_widget(), btn1) self.assertEqual(test, [True, False, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [btn1, [btn1, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur1) + self.assertEqual(get_cursor(), cur1) menu.update(PygameEventUtils.middle_rect_mouse_motion(btn2)) self.assertEqual(menu.get_selected_widget(), btn2) self.assertEqual(test, [True, True, True, False]) self.assertEqual(WIDGET_MOUSEOVER, [btn2, [btn2, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur2) + self.assertEqual(get_cursor(), cur2) menu.update(mouse_away_event) self.assertEqual(test, [True, True, True, True]) self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) menu.update(mouse_away_event) self.assertEqual(test, [True, True, True, True]) self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) self.assertEqual(menu.get_selected_widget(), btn2) # Mouseover btn1, but then hide it @@ -1897,37 +1899,37 @@ class MenuTest(unittest.TestCase): menu.update(PygameEventUtils.middle_rect_mouse_motion(btn1)) self.assertEqual(test, [True, False, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [btn1, [btn1, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur1) + self.assertEqual(get_cursor(), cur1) btn1.hide() self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) # Test close menu.update(PygameEventUtils.middle_rect_mouse_motion(btn2)) self.assertEqual(test, [True, True, True, False]) self.assertEqual(WIDGET_MOUSEOVER, [btn2, [btn2, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur2) + self.assertEqual(get_cursor(), cur2) menu.disable() self.assertEqual(test, [True, True, True, True]) self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) btn2.mouseleave(PygameEventUtils.middle_rect_mouse_motion(btn2)) self.assertEqual(test, [True, True, True, True]) self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) # Enable menu.enable() menu.update(PygameEventUtils.middle_rect_mouse_motion(btn2)) self.assertEqual(test, [True, True, False, True]) self.assertEqual(WIDGET_MOUSEOVER, [btn2, [btn2, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur2) + self.assertEqual(get_cursor(), cur2) # Move to hidden menu.update(PygameEventUtils.middle_rect_mouse_motion(btn1)) self.assertEqual(test, [True, True, False, False]) self.assertEqual(WIDGET_MOUSEOVER, [None, []]) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) # Unhide btn1.show() @@ -1954,13 +1956,13 @@ class MenuTest(unittest.TestCase): # Select btn1 menu.update(PygameEventUtils.middle_rect_mouse_motion(btn1)) self.assertEqual(WIDGET_MOUSEOVER, [btn1, [btn1, cur_none, []]]) - self.assertEqual(pygame.mouse.get_cursor(), cur1) + self.assertEqual(get_cursor(), cur1) # Change previous cursor to assert an error self.assertEqual(cur_none, WIDGET_TOP_CURSOR[0]) WIDGET_MOUSEOVER[1][1] = cur2 menu.update(mouse_away_event) - self.assertEqual(pygame.mouse.get_cursor(), cur_none) + self.assertEqual(get_cursor(), cur_none) # noinspection SpellCheckingInspection def test_floating_pos(self) -> None:
get_cursor() removed from SDL2 **Environment information** - OS: Ubuntu 20.04 - python version: v3.7 - pygame version: v2.0.0 - pygame-menu version: v4.0.4 **Bug description** In SDL2, the `pygame.mouse.get_cursor()` function has been removed, see https://www.pygame.org/docs/ref/mouse.html#pygame.mouse.get_cursor . To be compatible, `pygame-menu` shall not use the `get_cursor()` function. Currently the following line throw an error: https://github.com/ppizarror/pygame-menu/blob/9e21edadbaf4b8e013d2590d0941c9b0377ba5be/pygame_menu/widgets/core/widget.py#L598-L602 ```python File "/usr/local/lib/python3.8/dist-packages/pygame_menu/menu.py", line 2590, in update widget._check_mouseover(event) File "/usr/local/lib/python3.8/dist-packages/pygame_menu/widgets/core/widget.py", line 679, in _check_mouseover self.mouseover(event, check_all_widget_mouseleave) File "/usr/local/lib/python3.8/dist-packages/pygame_menu/widgets/core/widget.py", line 600, in mouseover previous_cursor = pygame.mouse.get_cursor() # Previous cursor TypeError: The get_cursor method is unavailable in SDL2 ```
0.0
9d231a56310b936c47f85bb80e2f331e8d85a137
[ "test/test_base.py::BaseTest::test_attributes", "test/test_base.py::BaseTest::test_classid", "test/test_base.py::BaseTest::test_counter", "test/test_base.py::BaseTest::test_repr", "test/test_controls.py::ControlsTest::test_config", "test/test_frame.py::test_reset_surface", "test/test_frame.py::FrameWidgetTest::test_general", "test/test_frame.py::FrameWidgetTest::test_menu_support", "test/test_frame.py::FrameWidgetTest::test_mouseover", "test/test_frame.py::FrameWidgetTest::test_resize", "test/test_frame.py::FrameWidgetTest::test_scrollarea", "test/test_frame.py::FrameWidgetTest::test_scrollarea_frame_within_scrollarea", "test/test_frame.py::FrameWidgetTest::test_sort", "test/test_frame.py::FrameWidgetTest::test_table", "test/test_frame.py::FrameWidgetTest::test_title", "test/test_menu.py::test_reset_surface", "test/test_menu.py::MenuTest::test_add_generic_widget", "test/test_menu.py::MenuTest::test_back_event", "test/test_menu.py::MenuTest::test_baseimage_selector", "test/test_menu.py::MenuTest::test_beforeopen", "test/test_menu.py::MenuTest::test_centering", "test/test_menu.py::MenuTest::test_close", "test/test_menu.py::MenuTest::test_columns_menu", "test/test_menu.py::MenuTest::test_copy", "test/test_menu.py::MenuTest::test_decorator", "test/test_menu.py::MenuTest::test_depth", "test/test_menu.py::MenuTest::test_empty", "test/test_menu.py::MenuTest::test_enabled", "test/test_menu.py::MenuTest::test_events", "test/test_menu.py::MenuTest::test_floating_pos", "test/test_menu.py::MenuTest::test_focus", "test/test_menu.py::MenuTest::test_generic_events", "test/test_menu.py::MenuTest::test_get_selected_widget", "test/test_menu.py::MenuTest::test_get_widget", "test/test_menu.py::MenuTest::test_getters", "test/test_menu.py::MenuTest::test_input_data", "test/test_menu.py::MenuTest::test_invalid_args", "test/test_menu.py::MenuTest::test_mainloop_kwargs", "test/test_menu.py::MenuTest::test_mouse_empty_submenu", "test/test_menu.py::MenuTest::test_mouseover_widget", "test/test_menu.py::MenuTest::test_position", "test/test_menu.py::MenuTest::test_reset_value", "test/test_menu.py::MenuTest::test_screen_dimension", "test/test_menu.py::MenuTest::test_set_title", "test/test_menu.py::MenuTest::test_size_constructor", "test/test_menu.py::MenuTest::test_submenu", "test/test_menu.py::MenuTest::test_surface_cache", "test/test_menu.py::MenuTest::test_time_draw", "test/test_menu.py::MenuTest::test_touchscreen", "test/test_menu.py::MenuTest::test_translate", "test/test_menu.py::MenuTest::test_visible", "test/test_menu.py::MenuTest::test_widget_move_index" ]
[]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2021-05-11 18:29:26+00:00
mit
4,641
ppizarror__pygame-menu-357
diff --git a/pygame_menu/version.py b/pygame_menu/version.py index ada8d44c..3cff547a 100644 --- a/pygame_menu/version.py +++ b/pygame_menu/version.py @@ -57,6 +57,6 @@ class Version(tuple): patch = property(lambda self: self[2]) -vernum = Version(4, 1, 0) +vernum = Version(4, 1, 1) ver = str(vernum) rev = '' diff --git a/pygame_menu/widgets/widget/rangeslider.py b/pygame_menu/widgets/widget/rangeslider.py index f7d4d662..9d9fa4a1 100644 --- a/pygame_menu/widgets/widget/rangeslider.py +++ b/pygame_menu/widgets/widget/rangeslider.py @@ -816,7 +816,6 @@ class RangeSlider(Widget): sw = surface.get_width() / 2 if surface is not None else 0 if len(self._range_values) == 2: d = float(value - self._range_values[0]) / (self._range_values[1] - self._range_values[0]) - assert 0 <= d <= 1 return int(d * self._range_width - sw) # Find nearest position
ppizarror/pygame-menu
0788c1842603c3b004b1acfa498207a60ff36d15
diff --git a/test/test_widget_rangeslider.py b/test/test_widget_rangeslider.py index 4737e879..4b498bc4 100644 --- a/test/test_widget_rangeslider.py +++ b/test/test_widget_rangeslider.py @@ -471,6 +471,23 @@ class RangeSliderWidgetTest(BaseTest): r = menu.add.range_slider('', 0.5, (0, 1), 0.1) self.assertEqual(r.get_size(), (198, 66)) + def test_invalid_range(self) -> None: + """ + Test invalid ranges. #356 + """ + menu = MenuUtils.generic_menu() + r = menu.add.range_slider('Infection Rate', default=2, increment=0.5, range_values=(2, 10)) + self.assertEqual(r.get_value(), 2) + self.assertTrue(r.update(PygameEventUtils.key(ctrl.KEY_RIGHT, keydown=True))) + self.assertEqual(r.get_value(), 2.5) + self.assertTrue(r.update(PygameEventUtils.key(ctrl.KEY_LEFT, keydown=True))) + self.assertEqual(r.get_value(), 2) + self.assertFalse(r.update(PygameEventUtils.key(ctrl.KEY_LEFT, keydown=True))) + self.assertEqual(r.get_value(), 2) + for _ in range(20): + r.update(PygameEventUtils.key(ctrl.KEY_RIGHT, keydown=True)) + self.assertEqual(r.get_value(), 10) + def test_value(self) -> None: """ Test rangeslider value.
RangeSlider assertion error when modifying minimum range value **Environment information** Describe your environment information, such as: - SO: Windows - python version: v3.8.5 - pygame version: v2.0.1 - pygame-menu version: v4.1.0 **Describe the bug** `options.add.range_slider("Infection Rate", default = 2,increment=0.5, range_values=(2,10))` This line throws an assertion error shown below. If the minimum value is set to 0, this works fine. It appears almost any minimum range value other than 0 throws an error. Commenting out the assertion in source seemed to work fine. `Traceback (most recent call last): File "main.py", line 120, in <module> g = Game() File "main.py", line 25, in __init__ self.options = optionsMenu(lambda : self._update_from_selection(3)) File "D:\School\Python\Sickulator\src\sickulator\menus.py", line 29, in optionsMenu options.add.range_slider("Infection Rate", default = 2,increment=0.5, range_values=(2,10)) File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\_widgetmanager.py", line 2816, in range_slider self._configure_widget(widget=widget, **attributes) File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\_widgetmanager.py", line 305, in _configure_widget widget.set_font( File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\widgets\core\widget.py", line 1711, in set_font self._force_render() File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\widgets\core\widget.py", line 802, in _force_render return self._render() File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\widgets\widget\rangeslider.py", line 795, in _render st_x = self._range_pos[0] + self._get_pos_range(v, st) File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\widgets\widget\rangeslider.py", line 819, in _get_pos_range assert 0 <= d <= 1 AssertionError` **To Reproduce** Create a menu, add a range_slider with range_values of 2 to 10 (or any number other than 0 to any value). **Expected behavior** It should successfully produce the range slider
0.0
0788c1842603c3b004b1acfa498207a60ff36d15
[ "test/test_widget_rangeslider.py::RangeSliderWidgetTest::test_invalid_range" ]
[ "test/test_widget_rangeslider.py::RangeSliderWidgetTest::test_double", "test/test_widget_rangeslider.py::RangeSliderWidgetTest::test_double_discrete", "test/test_widget_rangeslider.py::RangeSliderWidgetTest::test_empty_title", "test/test_widget_rangeslider.py::RangeSliderWidgetTest::test_kwargs", "test/test_widget_rangeslider.py::RangeSliderWidgetTest::test_single_discrete", "test/test_widget_rangeslider.py::RangeSliderWidgetTest::test_single_rangeslider", "test/test_widget_rangeslider.py::RangeSliderWidgetTest::test_value" ]
{ "failed_lite_validators": [ "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2021-06-14 21:41:07+00:00
mit
4,642
ppizarror__pygame-menu-401
diff --git a/pygame_menu/_scrollarea.py b/pygame_menu/_scrollarea.py index f0d8d3cc..b5cf6c34 100644 --- a/pygame_menu/_scrollarea.py +++ b/pygame_menu/_scrollarea.py @@ -574,6 +574,19 @@ class ScrollArea(Base): return self + def get_border_size(self) -> Tuple2IntType: + """ + Return the border size (width, height) in px. + + :return: Border width, height + """ + if isinstance(self._border_color, pygame_menu.BaseImage): # Image + return self._border_tiles_size + else: # Color + if self._border_color is None: + return 0, 0 + return self._border_width, self._border_width + def get_hidden_width(self) -> int: """ Return the total width out of the bounds of the viewable area. diff --git a/pygame_menu/menu.py b/pygame_menu/menu.py index 47d7b85e..99f76123 100644 --- a/pygame_menu/menu.py +++ b/pygame_menu/menu.py @@ -1835,7 +1835,7 @@ class Menu(Base): return self._scrollarea.get_scrollbar_thickness(ORIENTATION_HORIZONTAL), \ self._scrollarea.get_scrollbar_thickness(ORIENTATION_VERTICAL) - def get_width(self, inner: bool = False, widget: bool = False) -> int: + def get_width(self, inner: bool = False, widget: bool = False, border: bool = False) -> int: """ Get the Menu width. @@ -1847,15 +1847,17 @@ class Menu(Base): :param inner: If ``True`` returns the available width (menu width minus scroll if visible) :param widget: If ``True`` returns the total width used by the widgets + :param border: If ``True`` add the mmenu border width. Only applied if both ``inner`` and ``widget`` are ``False`` :return: Width in px """ if widget: return int(self._widget_max_position[0] - self._widget_min_position[0]) if not inner: - return int(self._width) + bw = 0 if not border else 2 * self._scrollarea.get_border_size()[0] + return int(self._width) + bw return int(self._width - self._get_scrollbar_thickness()[1]) - def get_height(self, inner: bool = False, widget: bool = False) -> int: + def get_height(self, inner: bool = False, widget: bool = False, border: bool = False) -> int: """ Get the Menu height. @@ -1867,15 +1869,17 @@ class Menu(Base): :param inner: If ``True`` returns the available height (menu height minus scroll and menubar) :param widget: If ``True`` returns the total height used by the widgets + :param border: If ``True`` add the menu border height. Only applied if both ``inner`` and ``widget`` are ``False`` :return: Height in px """ if widget: return int(self._widget_max_position[1] - self._widget_min_position[1]) if not inner: - return int(self._height) + bh = 0 if not border else 2 * self._scrollarea.get_border_size()[1] + return int(self._height) + bh return int(self._height - self._menubar.get_height() - self._get_scrollbar_thickness()[0]) - def get_size(self, inner: bool = False, widget: bool = False) -> Vector2IntType: + def get_size(self, inner: bool = False, widget: bool = False, border: bool = False) -> Vector2IntType: """ Return the Menu size as a tuple of (width, height) in px. @@ -1885,11 +1889,13 @@ class Menu(Base): stored in ``_current`` pointer); for such behaviour apply to :py:meth:`pygame_menu.menu.Menu.get_current` object. - :param inner: If ``True`` returns the available (width, height) (menu height minus scroll and menubar) + :param inner: If ``True`` returns the available size (width, height) (menu height minus scroll and menubar) :param widget: If ``True`` returns the total (width, height) used by the widgets + :param border: If ``True`` add the border size to the dimensions (width, height). Only applied if both ``inner`` and ``widget`` are ``False`` :return: Tuple of (width, height) in px """ - return self.get_width(inner=inner, widget=widget), self.get_height(inner=inner, widget=widget) + return self.get_width(inner=inner, widget=widget, border=border), \ + self.get_height(inner=inner, widget=widget, border=border) def render(self) -> 'Menu': """ @@ -2454,25 +2460,25 @@ class Menu(Base): continue if event.key == ctrl.KEY_MOVE_DOWN: - if self._current._down(): + if self._current._down(apply_sound=True): self._current._last_update_mode.append(_events.MENU_LAST_MOVE_DOWN) updated = True break elif event.key == ctrl.KEY_MOVE_UP: - if self._current._up(): + if self._current._up(apply_sound=True): self._current._last_update_mode.append(_events.MENU_LAST_MOVE_UP) updated = True break elif event.key == ctrl.KEY_LEFT: - if self._current._left(): + if self._current._left(apply_sound=True): self._current._last_update_mode.append(_events.MENU_LAST_MOVE_LEFT) updated = True break elif event.key == ctrl.KEY_RIGHT: - if self._current._right(): + if self._current._right(apply_sound=True): self._current._last_update_mode.append(_events.MENU_LAST_MOVE_RIGHT) updated = True break
ppizarror/pygame-menu
1932dd71ed3eb0126f20ccedb72d1b1393d73569
diff --git a/test/test_menu.py b/test/test_menu.py index cf76c186..06271e17 100644 --- a/test/test_menu.py +++ b/test/test_menu.py @@ -2417,6 +2417,37 @@ class MenuTest(BaseRSTest): sa.show_scrollbars(pygame_menu.locals.ORIENTATION_VERTICAL, force=False) self.assertEqual(sa.get_size(inner=True), (580, 400)) + def test_get_size(self) -> None: + """ + Test get menu size. + """ + theme = pygame_menu.themes.THEME_DEFAULT.copy() + menu = MenuUtils.generic_menu(theme=theme) + self.assertEqual(menu.get_size(), (600, 400)) + + # Create new menu with image border + for scale in [(1, 1), (2, 5), (5, 2)]: + theme.border_color = pygame_menu.BaseImage(pygame_menu.baseimage.IMAGE_EXAMPLE_TILED_BORDER) + theme.border_color.scale(*scale) + border_size = theme.border_color.get_size() + menu = MenuUtils.generic_menu(theme=theme) + self.assertEqual(menu.get_size(), (600, 400)) + self.assertEqual(menu.get_size(border=True), + (600 + 2 * border_size[0] / 3, 400 + 2 * border_size[1] / 3)) + + # Create new menu with border color + theme.border_width = 10 + theme.border_color = 'red' + menu = MenuUtils.generic_menu(theme=theme) + self.assertEqual(menu.get_size(border=True), + (600 + 2 * theme.border_width, 400 + 2 * theme.border_width)) + + # Menu menu with none border color + theme.border_width = 10 + theme.border_color = None + menu = MenuUtils.generic_menu(theme=theme) + self.assertEqual(menu.get_size(border=True), (600, 400)) + def test_border_color(self) -> None: """ Test menu border color.
Query the size of the menu including the border A related thing that would be useful is a way to query the size of the menu including the border, for placement purposes. _Originally posted by @vnmabus in https://github.com/ppizarror/pygame-menu/issues/390#issuecomment-1079982395_
0.0
1932dd71ed3eb0126f20ccedb72d1b1393d73569
[ "test/test_menu.py::MenuTest::test_get_size" ]
[ "test/test_menu.py::MenuTest::test_add_generic_widget", "test/test_menu.py::MenuTest::test_back_event", "test/test_menu.py::MenuTest::test_baseimage_selector", "test/test_menu.py::MenuTest::test_beforeopen", "test/test_menu.py::MenuTest::test_border_color", "test/test_menu.py::MenuTest::test_centering", "test/test_menu.py::MenuTest::test_close", "test/test_menu.py::MenuTest::test_columns_menu", "test/test_menu.py::MenuTest::test_copy", "test/test_menu.py::MenuTest::test_decorator", "test/test_menu.py::MenuTest::test_depth", "test/test_menu.py::MenuTest::test_empty", "test/test_menu.py::MenuTest::test_enabled", "test/test_menu.py::MenuTest::test_events", "test/test_menu.py::MenuTest::test_float_position", "test/test_menu.py::MenuTest::test_floating_pos", "test/test_menu.py::MenuTest::test_focus", "test/test_menu.py::MenuTest::test_generic_events", "test/test_menu.py::MenuTest::test_get_selected_widget", "test/test_menu.py::MenuTest::test_get_widget", "test/test_menu.py::MenuTest::test_getters", "test/test_menu.py::MenuTest::test_input_data", "test/test_menu.py::MenuTest::test_invalid_args", "test/test_menu.py::MenuTest::test_mainloop_disabled", "test/test_menu.py::MenuTest::test_mainloop_kwargs", "test/test_menu.py::MenuTest::test_mouse_empty_submenu", "test/test_menu.py::MenuTest::test_mouseover_widget", "test/test_menu.py::MenuTest::test_position", "test/test_menu.py::MenuTest::test_remove_widget", "test/test_menu.py::MenuTest::test_reset_value", "test/test_menu.py::MenuTest::test_resize", "test/test_menu.py::MenuTest::test_screen_dimension", "test/test_menu.py::MenuTest::test_set_title", "test/test_menu.py::MenuTest::test_size_constructor", "test/test_menu.py::MenuTest::test_submenu", "test/test_menu.py::MenuTest::test_surface_cache", "test/test_menu.py::MenuTest::test_theme_params", "test/test_menu.py::MenuTest::test_time_draw", "test/test_menu.py::MenuTest::test_touchscreen", "test/test_menu.py::MenuTest::test_translate", "test/test_menu.py::MenuTest::test_visible", "test/test_menu.py::MenuTest::test_widget_move_index" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2022-04-02 21:39:09+00:00
mit
4,643
ppizarror__pygame-menu-454
diff --git a/pygame_menu/font.py b/pygame_menu/font.py index 5378659a..2fe87dff 100644 --- a/pygame_menu/font.py +++ b/pygame_menu/font.py @@ -39,7 +39,7 @@ __all__ = [ ] from pathlib import Path -from typing import Union, Optional, Any +from typing import Union, Optional, Any, Dict, Tuple import os.path as path import pygame.font as __font @@ -71,12 +71,12 @@ FONT_EXAMPLES = (FONT_8BIT, FONT_BEBAS, FONT_COMIC_NEUE, FONT_DIGITAL, FONT_FRAN FONT_PT_SERIF, FONT_FIRACODE, FONT_FIRACODE_BOLD, FONT_FIRACODE_ITALIC, FONT_FIRACODE_BOLD_ITALIC) -# Stores font cache -_cache = {} - FontType = Union[str, __font.Font, Path] FontInstance = (str, __font.Font, Path) +# Stores font cache +_cache: Dict[Tuple[FontType, int], '__font.Font'] = {} + def assert_font(font: Any) -> None: """ diff --git a/pygame_menu/menu.py b/pygame_menu/menu.py index c40a9dad..2ec416d0 100644 --- a/pygame_menu/menu.py +++ b/pygame_menu/menu.py @@ -603,21 +603,29 @@ class Menu(Base): width: NumberType, height: NumberType, screen_dimension: Optional[Vector2IntType] = None, - position: Optional[Union[Vector2NumberType, Tuple[NumberType, NumberType, bool]]] = None + position: Optional[Union[Vector2NumberType, Tuple[NumberType, NumberType, bool]]] = None, + recursive: bool = False ) -> 'Menu': """ - Resize the menu to another width/height + Resizes the menu to another width/height. :param width: Menu width (px) :param height: Menu height (px) :param screen_dimension: List/Tuple representing the dimensions the Menu should reference for sizing/positioning (width, height), if ``None`` pygame is queried for the display mode. This value defines the ``window_size`` of the Menu :param position: Position on x-axis and y-axis. If the value is only 2 elements, the position is relative to the window width (thus, values must be 0-100%); else, the third element defines if the position is relative or not. If ``(x, y, False)`` the values of ``(x, y)`` are in px. If ``None`` use the default from the menu constructor + :param recursive: If true, resize all submenus in a recursive fashion :return: Self reference """ assert isinstance(width, NumberInstance) assert isinstance(height, NumberInstance) assert width > 0 and height > 0, \ 'menu width and height must be greater than zero' + assert isinstance(recursive, bool) + + # Resize recursively + if recursive: + for menu in self.get_submenus(True): + menu.resize(width, height, screen_dimension, position) # Convert to int width, height = int(width), int(height) diff --git a/pygame_menu/version.py b/pygame_menu/version.py index b9b93a75..6103afff 100644 --- a/pygame_menu/version.py +++ b/pygame_menu/version.py @@ -34,6 +34,6 @@ class Version(tuple): patch = property(lambda self: self[2]) -vernum = Version(4, 3, 8) +vernum = Version(4, 3, 9) ver = str(vernum) rev = '' diff --git a/pygame_menu/widgets/widget/table.py b/pygame_menu/widgets/widget/table.py index 976e04e1..cb751e15 100644 --- a/pygame_menu/widgets/widget/table.py +++ b/pygame_menu/widgets/widget/table.py @@ -265,9 +265,9 @@ class Table(Frame): # If cells is a previous table row if isinstance(cells, Frame) and cells.has_attribute('is_row'): - row_cells = list(cells.get_widgets(unpack_subframes=False)) + _row_cells = list(cells.get_widgets(unpack_subframes=False)) cells.clear() - cells = row_cells + cells = _row_cells if isinstance(cells, Widget): cells = [cells]
ppizarror/pygame-menu
9c2e1e5024a5023d3b8cf30dd5873d5ebb9a34ba
diff --git a/test/_utils.py b/test/_utils.py index 72b0350e..46b88295 100644 --- a/test/_utils.py +++ b/test/_utils.py @@ -21,11 +21,9 @@ __all__ = [ 'reset_widgets_over', 'sleep', 'surface', - 'test_reset_surface', # Class utils 'BaseTest', - 'BaseRSTest', 'PygameEventUtils', 'MenuUtils' @@ -94,18 +92,18 @@ class BaseTest(unittest.TestCase): Base test class. """ - -class BaseRSTest(unittest.TestCase): - """ - Test class that Reset the Surface (RS) each time a test runs. - """ - def setUp(self) -> None: """ Reset the surface. """ test_reset_surface() + def tearDown(self) -> None: + """ + Reset the surface. + """ + test_reset_surface() + class PygameEventUtils(object): """ diff --git a/test/test_examples.py b/test/test_examples.py index 53952eac..6834394d 100644 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -8,7 +8,7 @@ Test example files. __all__ = ['ExamplesTest'] -from test._utils import BaseRSTest, MenuUtils, PygameEventUtils, test_reset_surface +from test._utils import BaseTest, MenuUtils, PygameEventUtils import pygame import pygame_menu @@ -30,11 +30,8 @@ import pygame_menu.examples.other.scrollbar_area as scrollbar_area import pygame_menu.examples.other.ui_solar_system as ui_solarsystem import pygame_menu.examples.other.widget_positioning as widget_positioning -# Reset the surface as some example could have changed it -test_reset_surface() - -class ExamplesTest(BaseRSTest): +class ExamplesTest(BaseTest): def test_example_game_selector(self) -> None: """ diff --git a/test/test_menu.py b/test/test_menu.py index 4a390646..e95f83f8 100644 --- a/test/test_menu.py +++ b/test/test_menu.py @@ -8,7 +8,7 @@ Menu object tests. __all__ = ['MenuTest'] -from test._utils import BaseRSTest, surface, MenuUtils, PygameEventUtils, \ +from test._utils import BaseTest, surface, MenuUtils, PygameEventUtils, \ TEST_THEME, PYGAME_V2, WIDGET_MOUSEOVER, WIDGET_TOP_CURSOR, reset_widgets_over, \ THEME_NON_FIXED_TITLE import copy @@ -40,7 +40,7 @@ def dummy_function() -> None: return -class MenuTest(BaseRSTest): +class MenuTest(BaseTest): def test_mainloop_disabled(self) -> None: """ @@ -2378,7 +2378,7 @@ class MenuTest(BaseRSTest): self.assertEqual(menu._column_max_width, [300]) self.assertEqual(menu._menubar._width, 300) - # render + # Render self.assertIsNone(menu._widgets_surface) menu.render() self.assertIsNotNone(menu._widgets_surface) @@ -2435,6 +2435,19 @@ class MenuTest(BaseRSTest): sa.show_scrollbars(pygame_menu.locals.ORIENTATION_VERTICAL, force=False) self.assertEqual(sa.get_size(inner=True), (580, 400)) + # Test submenu recursive resizing + menu = MenuUtils.generic_menu(theme=theme) + menu2 = MenuUtils.generic_menu(theme=theme) + menu3 = MenuUtils.generic_menu(theme=theme) + menu.add.button('btn', menu2) + menu2.add.button('btn', menu3) + self.assertEqual(menu.get_submenus(True), (menu2, menu3)) + for m in (menu, menu2, menu3): + self.assertEqual(m.get_size(), (600, 400)) + menu.resize(300, 300, recursive=True) # Now, resize + for m in (menu, menu2, menu3): + self.assertEqual(m.get_size(), (300, 300)) + def test_get_size(self) -> None: """ Test get menu size. diff --git a/test/test_scrollarea.py b/test/test_scrollarea.py index acf22bf1..30eda782 100644 --- a/test/test_scrollarea.py +++ b/test/test_scrollarea.py @@ -150,6 +150,10 @@ class ScrollAreaTest(BaseTest): s1.hide() self.assertFalse(s1.is_visible()) + # Check scrollbar render + s1._slider_rect = None + self.assertIsNone(s1._render()) + def test_size(self) -> None: """ Test size. diff --git a/test/test_widget_frame.py b/test/test_widget_frame.py index e7ea673f..f6921b1d 100644 --- a/test/test_widget_frame.py +++ b/test/test_widget_frame.py @@ -9,9 +9,8 @@ its layout and contains other widgets. __all__ = ['FrameWidgetTest'] -from test._utils import MenuUtils, surface, PygameEventUtils, test_reset_surface, \ +from test._utils import BaseTest, MenuUtils, surface, PygameEventUtils, \ TEST_THEME, PYGAME_V2, WIDGET_MOUSEOVER, reset_widgets_over, THEME_NON_FIXED_TITLE -import unittest import pygame import pygame_menu @@ -30,13 +29,7 @@ from pygame_menu._scrollarea import get_scrollbars_from_position from pygame_menu.widgets.widget.frame import _FrameDoNotAcceptScrollarea -class FrameWidgetTest(unittest.TestCase): - - def setUp(self) -> None: - """ - Setup frame widget test. - """ - test_reset_surface() +class FrameWidgetTest(BaseTest): def test_general(self) -> None: """
Resize all submenus **Environment information** - OS: Mac OSX - python version: v3.7 - pygame version: v2.x - pygame-menu version: v4.3.8 **Describe the bug** When resizing menu using `menu.resize(width, height)`, submenu are not resized. **Expected behavior** Is there any easy method to pass new size to all submenus?
0.0
9c2e1e5024a5023d3b8cf30dd5873d5ebb9a34ba
[ "test/test_menu.py::MenuTest::test_resize" ]
[ "test/_utils.py::test_reset_surface", "test/test_examples.py::ExamplesTest::test_example_game_selector", "test/test_examples.py::ExamplesTest::test_example_multi_input", "test/test_examples.py::ExamplesTest::test_example_other_calculator", "test/test_examples.py::ExamplesTest::test_example_other_dynamic_button_append", "test/test_examples.py::ExamplesTest::test_example_other_dynamic_widget_update", "test/test_examples.py::ExamplesTest::test_example_other_image_background", "test/test_examples.py::ExamplesTest::test_example_other_maze", "test/test_examples.py::ExamplesTest::test_example_other_scrollbar", "test/test_examples.py::ExamplesTest::test_example_other_scrollbar_area", "test/test_examples.py::ExamplesTest::test_example_other_ui_solar_system", "test/test_examples.py::ExamplesTest::test_example_other_widget_positioning", "test/test_examples.py::ExamplesTest::test_example_resizable_window", "test/test_examples.py::ExamplesTest::test_example_scroll_menu", "test/test_examples.py::ExamplesTest::test_example_simple", "test/test_examples.py::ExamplesTest::test_example_timer_clock", "test/test_menu.py::MenuTest::test_add_generic_widget", "test/test_menu.py::MenuTest::test_back_event", "test/test_menu.py::MenuTest::test_baseimage_selector", "test/test_menu.py::MenuTest::test_beforeopen", "test/test_menu.py::MenuTest::test_border_color", "test/test_menu.py::MenuTest::test_centering", "test/test_menu.py::MenuTest::test_close", "test/test_menu.py::MenuTest::test_columns_menu", "test/test_menu.py::MenuTest::test_copy", "test/test_menu.py::MenuTest::test_decorator", "test/test_menu.py::MenuTest::test_depth", "test/test_menu.py::MenuTest::test_empty", "test/test_menu.py::MenuTest::test_enabled", "test/test_menu.py::MenuTest::test_events", "test/test_menu.py::MenuTest::test_float_position", "test/test_menu.py::MenuTest::test_floating_pos", "test/test_menu.py::MenuTest::test_focus", "test/test_menu.py::MenuTest::test_generic_events", "test/test_menu.py::MenuTest::test_get_selected_widget", "test/test_menu.py::MenuTest::test_get_size", "test/test_menu.py::MenuTest::test_get_widget", "test/test_menu.py::MenuTest::test_getters", "test/test_menu.py::MenuTest::test_input_data", "test/test_menu.py::MenuTest::test_invalid_args", "test/test_menu.py::MenuTest::test_mainloop_disabled", "test/test_menu.py::MenuTest::test_mainloop_kwargs", "test/test_menu.py::MenuTest::test_menu_render_toggle", "test/test_menu.py::MenuTest::test_menu_widget_selected_events", "test/test_menu.py::MenuTest::test_mouse_empty_submenu", "test/test_menu.py::MenuTest::test_mouseover_widget", "test/test_menu.py::MenuTest::test_position", "test/test_menu.py::MenuTest::test_remove_widget", "test/test_menu.py::MenuTest::test_reset_value", "test/test_menu.py::MenuTest::test_screen_dimension", "test/test_menu.py::MenuTest::test_set_title", "test/test_menu.py::MenuTest::test_size_constructor", "test/test_menu.py::MenuTest::test_submenu", "test/test_menu.py::MenuTest::test_surface_cache", "test/test_menu.py::MenuTest::test_theme_params", "test/test_menu.py::MenuTest::test_time_draw", "test/test_menu.py::MenuTest::test_touchscreen", "test/test_menu.py::MenuTest::test_translate", "test/test_menu.py::MenuTest::test_visible", "test/test_menu.py::MenuTest::test_widget_move_index", "test/test_scrollarea.py::ScrollAreaTest::test_bg_image", "test/test_scrollarea.py::ScrollAreaTest::test_change_area_color", "test/test_scrollarea.py::ScrollAreaTest::test_copy", "test/test_scrollarea.py::ScrollAreaTest::test_decorator", "test/test_scrollarea.py::ScrollAreaTest::test_empty_scrollarea", "test/test_scrollarea.py::ScrollAreaTest::test_position", "test/test_scrollarea.py::ScrollAreaTest::test_scrollarea_position", "test/test_scrollarea.py::ScrollAreaTest::test_scrollbars", "test/test_scrollarea.py::ScrollAreaTest::test_show_hide_scrollbars", "test/test_scrollarea.py::ScrollAreaTest::test_size", "test/test_scrollarea.py::ScrollAreaTest::test_surface_cache", "test/test_scrollarea.py::ScrollAreaTest::test_translate", "test/test_scrollarea.py::ScrollAreaTest::test_widget_relative_to_view_rect", "test/test_widget_frame.py::FrameWidgetTest::test_general", "test/test_widget_frame.py::FrameWidgetTest::test_make_scrollarea", "test/test_widget_frame.py::FrameWidgetTest::test_menu_support", "test/test_widget_frame.py::FrameWidgetTest::test_mouseover", "test/test_widget_frame.py::FrameWidgetTest::test_pack_columns", "test/test_widget_frame.py::FrameWidgetTest::test_resize", "test/test_widget_frame.py::FrameWidgetTest::test_scrollarea", "test/test_widget_frame.py::FrameWidgetTest::test_scrollarea_frame_within_scrollarea", "test/test_widget_frame.py::FrameWidgetTest::test_sort", "test/test_widget_frame.py::FrameWidgetTest::test_title", "test/test_widget_frame.py::FrameWidgetTest::test_value" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2023-03-08 13:49:29+00:00
mit
4,644
praekeltfoundation__marathon-acme-112
diff --git a/.travis.yml b/.travis.yml index 2046992..c0f46b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ branches: only: - develop - master - - /\d+\.\d+(\.\d+)?/ + - /^\d+\.\d+(\.\d+)?$/ language: python matrix: diff --git a/marathon_acme/marathon_util.py b/marathon_acme/marathon_util.py index 771939d..36b257c 100644 --- a/marathon_acme/marathon_util.py +++ b/marathon_acme/marathon_util.py @@ -2,46 +2,101 @@ def get_number_of_app_ports(app): """ Get the number of ports for the given app JSON. This roughly follows the logic in marathon-lb for finding app IPs/ports, although we are only - interested in the quantity of ports an app has: - https://github.com/mesosphere/marathon-lb/blob/v1.7.0/utils.py#L278-L350 + interested in the quantity of ports an app should have and don't consider + the specific IPs/ports of individual tasks: + https://github.com/mesosphere/marathon-lb/blob/v1.10.3/utils.py#L393-L415 :param app: The app JSON from the Marathon API. :return: The number of ports for the app. """ - if _is_ip_per_task(app): - if _is_user_network(app): - return len(app['container']['docker']['portMappings']) - else: - return len(app['ipAddress']['discovery']['ports']) + mode = _get_networking_mode(app) + ports_list = None + if mode == 'host': + ports_list = _get_port_definitions(app) + elif mode == 'container/bridge': + ports_list = _get_port_definitions(app) + if ports_list is None: + ports_list = _get_container_port_mappings(app) + elif mode == 'container': + ports_list = _get_ip_address_discovery_ports(app) + # Marathon 1.5+: the ipAddress field is missing -> ports_list is None + # Marathon <1.5: the ipAddress field can be present, but ports_list can + # still be empty while the container port mapping is not :-/ + if not ports_list: + ports_list = _get_container_port_mappings(app) else: - # Prefer the 'portDefinitions' field added in Marathon 1.0.0 but fall - # back to the deprecated 'ports' array if that's not present. - if 'portDefinitions' in app: - return len(app['portDefinitions']) - else: - return len(app['ports']) + raise RuntimeError( + "Unknown Marathon networking mode '{}'".format(mode)) + return len(ports_list) -def _is_ip_per_task(app): + +def _get_networking_mode(app): """ - Return whether the application is using IP-per-task. - :param app: The application to check. - :return: True if using IP per task, False otherwise. + Get the Marathon networking mode for the app. """ - return app.get('ipAddress') is not None + # Marathon 1.5+: there is a `networks` field + networks = app.get('networks') + if networks: + # Modes cannot be mixed, so assigning the last mode is fine + return networks[-1].get('mode', 'container') + + # Older Marathon: determine equivalent network mode + container = app.get('container') + if container is not None and 'docker' in container: + docker_network = container['docker'].get('network') + if docker_network == 'USER': + return 'container' + elif docker_network == 'BRIDGE': + return 'container/bridge' + + return 'container' if _is_legacy_ip_per_task(app) else 'host' -def _is_user_network(app): +def _get_container_port_mappings(app): """ - Returns True if container network mode is set to USER - :param app: The application to check. - :return: True if using USER network, False otherwise. + Get the ``portMappings`` field for the app container. """ - container = app.get('container') - if container is None: - return False + container = app['container'] + + # Marathon 1.5+: container.portMappings field + port_mappings = container.get('portMappings') + + # Older Marathon: container.docker.portMappings field + if port_mappings is None and 'docker' in container: + port_mappings = container['docker'].get('portMappings') - if container['type'] != 'DOCKER': - return False + return port_mappings - return container['docker']['network'] == 'USER' + +def _get_port_definitions(app): + """ + Get the ``portDefinitions`` field for the app if present. + """ + if 'portDefinitions' in app: + return app['portDefinitions'] + + # In the worst case try use the old `ports` array + # Only useful on very old Marathons + if 'ports' in app: + return app['ports'] + + return None + + +def _get_ip_address_discovery_ports(app): + """ + Get the ports from the ``ipAddress`` field for the app if present. + """ + if not _is_legacy_ip_per_task(app): + return None + return app['ipAddress']['discovery']['ports'] + + +def _is_legacy_ip_per_task(app): + """ + Return whether the application is using IP-per-task on Marathon < 1.5. + :param app: The application to check. + :return: True if using IP per task, False otherwise. + """ + return app.get('ipAddress') is not None
praekeltfoundation/marathon-acme
6f795e56fb80b6ce2e93ae3e33ec578eb13f6202
diff --git a/marathon_acme/tests/test_marathon_util.py b/marathon_acme/tests/test_marathon_util.py index e793424..9eb7c2f 100644 --- a/marathon_acme/tests/test_marathon_util.py +++ b/marathon_acme/tests/test_marathon_util.py @@ -1,4 +1,5 @@ import pytest +from testtools import ExpectedException from testtools.assertions import assert_that from testtools.matchers import Equals @@ -53,6 +54,19 @@ TEST_APP = { 'deployments': [], } +CONTAINER_HOST_NETWORKING = { + 'type': 'DOCKER', + 'volumes': [], + 'docker': { + 'image': 'praekeltfoundation/marathon-lb:1.6.0', + 'network': 'HOST', + 'portMappings': [], + 'privileged': True, + 'parameters': [], + 'forcePullImage': False + } +} + CONTAINER_USER_NETWORKING = { 'type': 'DOCKER', 'volumes': [], @@ -115,6 +129,77 @@ CONTAINER_MESOS = { ], } +# https://github.com/mesosphere/marathon/blob/v1.5.1/docs/docs/networking.md#host-mode +NETWORKS_CONTAINER_HOST_MARATHON15 = [{'mode': 'host'}] +CONTAINER_MESOS_HOST_NETWORKING_MARATHON15 = { + 'type': 'MESOS', + 'docker': { + 'image': 'my-image:1.0' + }, +} + +# https://github.com/mesosphere/marathon/blob/v1.5.1/docs/docs/networking.md#specifying-ports-1 +NETWORKS_CONTAINER_BRIDGE_MARATHON15 = [{'mode': 'container/bridge'}] +CONTAINER_BRIDGE_NETWORKING_MARATHON15 = { + 'type': 'DOCKER', + 'docker': { + 'forcePullImage': True, + 'image': 'praekeltfoundation/mc2:release-3.11.2', + 'parameters': [ + { + 'key': 'add-host', + 'value': 'servicehost:172.17.0.1' + } + ], + 'privileged': False + }, + 'volumes': [], + 'portMappings': [ + { + 'containerPort': 80, + 'hostPort': 0, + 'labels': {}, + 'protocol': 'tcp', + 'servicePort': 10005 + } + ] +} +CONTAINER_MESOS_BRIDGE_NETWORKING_MARATHON15 = { + 'type': 'MESOS', + 'docker': { + 'image': 'my-image:1.0' + }, + 'portMappings': [ + {'containerPort': 80, 'hostPort': 0, 'name': 'http'}, + {'containerPort': 443, 'hostPort': 0, 'name': 'https'}, + {'containerPort': 4000, 'hostPort': 0, 'name': 'mon'} + ] +} + +# https://github.com/mesosphere/marathon/blob/v1.5.1/docs/docs/networking.md#enabling-container-mode +NETWORKS_CONTAINER_USER_MARATHON15 = [{'mode': 'container', 'name': 'dcos'}] +CONTAINER_USER_NETWORKING_MARATHON15 = { + 'type': 'DOCKER', + 'docker': { + 'forcePullImage': False, + 'image': 'python:3-alpine', + 'parameters': [], + 'privileged': False + }, + 'volumes': [], + 'portMappings': [ + { + 'containerPort': 8080, + 'labels': { + 'VIP_0': '/foovu1:8080' + }, + 'name': 'foovu1http', + 'protocol': 'tcp', + 'servicePort': 10004 + } + ], +} + IP_ADDRESS_NO_PORTS = { 'groups': [], 'labels': {}, @@ -151,6 +236,17 @@ def test_app(): class TestGetNumberOfAppPortsFunc(object): + def test_host_networking(self, test_app): + """ + When the app uses Docker containers with HOST networking, the ports + should be counted from the 'portDefinitions' field. + """ + test_app['container'] = CONTAINER_HOST_NETWORKING + test_app['portDefinitions'] = PORT_DEFINITIONS_ONE_PORT + + num_ports = get_number_of_app_ports(test_app) + assert_that(num_ports, Equals(1)) + def test_user_networking(self, test_app): """ When the app uses a Docker container with USER networking, it will have @@ -207,3 +303,64 @@ class TestGetNumberOfAppPortsFunc(object): num_ports = get_number_of_app_ports(test_app) assert_that(num_ports, Equals(2)) + + def test_host_networking_mesos_marathon15(self, test_app): + """ + For Marathon 1.5+, when the app uses Mesos containers with host + networking, the ports should be counted from the 'portDefinitions' + field. + """ + test_app['container'] = CONTAINER_MESOS_HOST_NETWORKING_MARATHON15 + test_app['networks'] = NETWORKS_CONTAINER_HOST_MARATHON15 + test_app['portDefinitions'] = PORT_DEFINITIONS_ONE_PORT + + num_ports = get_number_of_app_ports(test_app) + assert_that(num_ports, Equals(1)) + + def test_bridge_networking_marathon15(self, test_app): + """ + For Marathon 1.5+, when the app uses Docker containers with + 'container/bridge' networking, the ports should be counted from the + ``container.portMappings`` field. + """ + test_app['container'] = CONTAINER_BRIDGE_NETWORKING_MARATHON15 + test_app['networks'] = NETWORKS_CONTAINER_BRIDGE_MARATHON15 + + num_ports = get_number_of_app_ports(test_app) + assert_that(num_ports, Equals(1)) + + def test_bridge_networking_mesos_marathon15(self, test_app): + """ + For Marathon 1.5+, when the app uses Mesos containers with + 'container/bridge' networking, the ports should be counted from the + ``container.portMappings`` field. + """ + test_app['container'] = CONTAINER_MESOS_BRIDGE_NETWORKING_MARATHON15 + test_app['networks'] = NETWORKS_CONTAINER_BRIDGE_MARATHON15 + + num_ports = get_number_of_app_ports(test_app) + assert_that(num_ports, Equals(3)) + + def test_user_networking_marathon15(self, test_app): + """ + For Marathon 1.5+, when the app uses Docker containers with 'container' + networking, the ports should be counted from the + ``container.portMappings`` field. + """ + test_app['container'] = CONTAINER_USER_NETWORKING_MARATHON15 + test_app['networks'] = NETWORKS_CONTAINER_USER_MARATHON15 + + num_ports = get_number_of_app_ports(test_app) + assert_that(num_ports, Equals(1)) + + def test_unknown_networking_mode(self, test_app): + """ + When an app is defined with an unknown networking mode, an error is + raised. + """ + test_app['networks'] = [{'mode': 'container/iptables'}] + + with ExpectedException( + RuntimeError, + r"Unknown Marathon networking mode 'container/iptables'"): + get_number_of_app_ports(test_app)
Support Marathon 1.5 networking API Marathon 1.5 isn't out yet but changes things up a lot: https://github.com/mesosphere/marathon/blob/master/docs/docs/networking.md
0.0
6f795e56fb80b6ce2e93ae3e33ec578eb13f6202
[ "marathon_acme/tests/test_marathon_util.py::TestGetNumberOfAppPortsFunc::test_bridge_networking_marathon15", "marathon_acme/tests/test_marathon_util.py::TestGetNumberOfAppPortsFunc::test_bridge_networking_mesos_marathon15", "marathon_acme/tests/test_marathon_util.py::TestGetNumberOfAppPortsFunc::test_user_networking_marathon15", "marathon_acme/tests/test_marathon_util.py::TestGetNumberOfAppPortsFunc::test_unknown_networking_mode" ]
[ "marathon_acme/tests/test_marathon_util.py::TestGetNumberOfAppPortsFunc::test_host_networking", "marathon_acme/tests/test_marathon_util.py::TestGetNumberOfAppPortsFunc::test_user_networking", "marathon_acme/tests/test_marathon_util.py::TestGetNumberOfAppPortsFunc::test_ip_per_task_no_container", "marathon_acme/tests/test_marathon_util.py::TestGetNumberOfAppPortsFunc::test_ip_per_task_mesos_containerizer", "marathon_acme/tests/test_marathon_util.py::TestGetNumberOfAppPortsFunc::test_bridge_networking", "marathon_acme/tests/test_marathon_util.py::TestGetNumberOfAppPortsFunc::test_bridge_networking_no_port_definitions", "marathon_acme/tests/test_marathon_util.py::TestGetNumberOfAppPortsFunc::test_host_networking_mesos_marathon15" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_hyperlinks", "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2017-10-03 12:22:02+00:00
mit
4,645
praekeltfoundation__seaworthy-92
diff --git a/.travis.yml b/.travis.yml index b4d4692..532ae77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,10 +18,6 @@ after_success: if [[ $TOXENV =~ py..-(full|pytest3) ]]; then codecov; fi jobs: include: - - env: TOXENV=py34-core,py34-pytest,py34-testtools,py34-full - python: '3.4' - services: docker - - env: TOXENV=py35-core,py35-pytest,py35-testtools,py35-full python: '3.5' services: docker diff --git a/seaworthy/containers/rabbitmq.py b/seaworthy/containers/rabbitmq.py index a4e3c4b..12b095a 100644 --- a/seaworthy/containers/rabbitmq.py +++ b/seaworthy/containers/rabbitmq.py @@ -20,9 +20,11 @@ class RabbitMQContainer(ContainerDefinition): Write more docs. """ - # For some reason this container is slower to start through seaworthy than - # with a plain `docker run`, so give it a bit more time to get going. :-( - WAIT_TIMEOUT = 20.0 + # There seems to be a weird interaction between the erlang runtime and + # something in docker which results in annoyingly long startup times in + # some environments. The best we can do to deal with that is to give it a + # bit more time to get going. :-( + WAIT_TIMEOUT = 30.0 DEFAULT_NAME = 'rabbitmq' DEFAULT_IMAGE = 'rabbitmq:alpine' @@ -51,6 +53,14 @@ class RabbitMQContainer(ContainerDefinition): self.user = user self.password = password + def wait_for_start(self): + """ + Wait for the RabbitMQ process to be come up. + """ + er = self.exec_rabbitmqctl( + 'wait', ['--pid', '1', '--timeout', str(int(self.wait_timeout))]) + output_lines(er, error_exc=TimeoutError) + def base_kwargs(self): """ Add a ``tmpfs`` entry for ``/var/lib/rabbitmq`` to avoid unnecessary diff --git a/seaworthy/utils.py b/seaworthy/utils.py index c2b1637..4eaa548 100644 --- a/seaworthy/utils.py +++ b/seaworthy/utils.py @@ -1,7 +1,7 @@ from docker.models.containers import ExecResult -def output_lines(output, encoding='utf-8'): +def output_lines(output, encoding='utf-8', error_exc=None): """ Convert bytestring container output or the result of a container exec command into a sequence of unicode lines. @@ -9,12 +9,19 @@ def output_lines(output, encoding='utf-8'): :param output: Container output bytes or an :class:`docker.models.containers.ExecResult` instance. - :param encoding: The encoding to use when converting bytes to unicode + :param encoding: + The encoding to use when converting bytes to unicode (default ``utf-8``). + :param error_exc: + Optional exception to raise if ``output`` is an ``ExecResult`` with a + nonzero exit code. :returns: list[str] + """ if isinstance(output, ExecResult): - _, output = output + exit_code, output = output + if exit_code != 0 and error_exc is not None: + raise error_exc(output.decode(encoding)) return output.decode(encoding).splitlines()
praekeltfoundation/seaworthy
8f59b021f885a2ef894faa1b9b6ca6a623c11b39
diff --git a/seaworthy/tests-core/test_utils.py b/seaworthy/tests-core/test_utils.py index 0067627..66c5260 100644 --- a/seaworthy/tests-core/test_utils.py +++ b/seaworthy/tests-core/test_utils.py @@ -18,3 +18,10 @@ class TestOutputLinesFunc(unittest.TestCase): def test_custom_encoding(self): """String lines can be parsed using a custom encoding.""" self.assertEqual(output_lines(b'\xe1', encoding='latin1'), ['á']) + + def test_exec_result_error_exc(self): + """ExecResult with nonzero exit code can raise exception.""" + with self.assertRaisesRegex(TimeoutError, 'x\r\ny'): + output_lines(ExecResult(128, b'x\r\ny'), error_exc=TimeoutError) + # No exception if the exit code is zero. + self.assertEqual(output_lines(ExecResult(0, b':-)')), [':-)'])
Use `rabbitmqctl wait` to wait for RabbitMQ containers to start https://www.rabbitmq.com/rabbitmqctl.8.html#wait
0.0
8f59b021f885a2ef894faa1b9b6ca6a623c11b39
[ "seaworthy/tests-core/test_utils.py::TestOutputLinesFunc::test_exec_result_error_exc" ]
[ "seaworthy/tests-core/test_utils.py::TestOutputLinesFunc::test_bytes", "seaworthy/tests-core/test_utils.py::TestOutputLinesFunc::test_custom_encoding", "seaworthy/tests-core/test_utils.py::TestOutputLinesFunc::test_exec_result" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_hyperlinks", "has_many_modified_files", "has_many_hunks", "has_pytest_match_arg" ], "has_test_patch": true, "is_lite": false }
2019-04-17 14:30:23+00:00
bsd-3-clause
4,646
praw-dev__praw-1307
diff --git a/CHANGES.rst b/CHANGES.rst index f0295367..ed334612 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,14 +20,29 @@ Unreleased * :meth:`~.Emoji.update` supports modifying an emoji's permissions. * :meth:`~.SubredditEmoji.add` now supports optionally passing booleans to set an emoji's permissions upon upload. +* Methods :meth:`.SubredditLinkFlairTemplates.update` and + :meth:`.SubredditRedditorFlairTemplates.update` contain a new parameter, + ``fetch``, that toggles the automatic fetching of existing data from Reddit. + It is set to True by default. +* Values in methods :meth:`.SubredditLinkFlairTemplates.update` and + :meth:`.SubredditRedditorFlairTemplates.update` that are left as the + defaults will no longer be over-written if the ``fetch`` parameter is set to + ``True``, but will fill in existing values for the flair template. +* The parameter ``text`` for methods + :meth:`.SubredditLinkFlairTemplates.update` and + :meth:`.SubredditRedditorFlairTemplates.update` is no longer required. **Removed** * Converting :class:`.APIException` to string will no longer escape unicode characters. -* Module ``praw.models.modaction`` no longer exists. Pleae use the module - ``praw.models.mod_action`` module, or directly import ``ModAction`` +* Module ``praw.models.modaction`` no longer exists. Please use the module + ``praw.models.mod_action``, or directly import ``ModAction`` from ``praw.models``. +* Methods :meth:`.SubredditLinkFlairTemplates.update` and + :meth:`.SubredditRedditorFlairTemplates.update` will no longer + create flairs that are using an invalid template id, but instead throw a + :class:`.InvalidFlairTemplateID`. 6.5.1 (2020/01/07) ------------------ diff --git a/praw/exceptions.py b/praw/exceptions.py index 5ecc6b73..0be01499 100644 --- a/praw/exceptions.py +++ b/praw/exceptions.py @@ -49,6 +49,19 @@ class DuplicateReplaceException(ClientException): ) +class InvalidFlairTemplateID(ClientException): + """Indicate exceptions where an invalid flair template id is given.""" + + def __init__(self, template_id: str): + """Initialize the class.""" + super().__init__( + "The flair template id ``{template_id}`` is invalid. If you are " + "trying to create a flair, please use the ``add`` method.".format( + template_id=template_id + ) + ) + + class InvalidImplicitAuth(ClientException): """Indicate exceptions where an implicit auth type is used incorrectly.""" diff --git a/praw/models/reddit/subreddit.py b/praw/models/reddit/subreddit.py index 876ecb29..2f861176 100644 --- a/praw/models/reddit/subreddit.py +++ b/praw/models/reddit/subreddit.py @@ -11,7 +11,12 @@ import websocket from prawcore import Redirect from ...const import API_PATH, JPEG_HEADER -from ...exceptions import APIException, ClientException, WebSocketException +from ...exceptions import ( + APIException, + ClientException, + InvalidFlairTemplateID, + WebSocketException, +) from ...util.cache import cachedproperty from ..listing.generator import ListingGenerator from ..listing.mixins import SubredditListingMixin @@ -1378,6 +1383,10 @@ class SubredditFlairTemplates: """ self.subreddit = subreddit + def __iter__(self): + """Abstract method to return flair templates.""" + raise NotImplementedError() + def _add( self, text, @@ -1429,19 +1438,20 @@ class SubredditFlairTemplates: def update( self, template_id, - text, - css_class="", - text_editable=False, + text=None, + css_class=None, + text_editable=None, background_color=None, text_color=None, mod_only=None, allowable_content=None, max_emojis=None, + fetch=True, ): """Update the flair template provided by ``template_id``. :param template_id: The flair template to update. If not valid then - a new flair template will be made. + an exception will be thrown. :param text: The flair template's new text (required). :param css_class: The flair template's new css_class (default: ''). :param text_editable: (boolean) Indicate if the flair text can be @@ -1458,6 +1468,12 @@ class SubredditFlairTemplates: valid emoji string, for example ``':snoo:'``. :param max_emojis: (int) Maximum emojis in the flair (Reddit defaults this value to 10). + :param fetch: Whether or not PRAW will fetch existing information on + the existing flair before updating (Default: True). + + .. warning:: If parameter ``fetch`` is set to ``False``, all parameters + not provided will be reset to default (``None`` or ``False``) + values. For example to make a user flair template text_editable, try: @@ -1469,11 +1485,6 @@ class SubredditFlairTemplates: template_info['flair_text'], text_editable=True) - .. note:: - - Any parameters not provided will be set to default values (usually - ``None`` or ``False``) on Reddit's end. - """ url = API_PATH["flairtemplate_v2"].format(subreddit=self.subreddit) data = { @@ -1487,6 +1498,19 @@ class SubredditFlairTemplates: "text_color": text_color, "text_editable": text_editable, } + if fetch: + _existing_data = [ + template + for template in iter(self) + if template["id"] == template_id + ] + if len(_existing_data) != 1: + raise InvalidFlairTemplateID(template_id) + else: + existing_data = _existing_data[0] + for key, value in existing_data.items(): + if data.get(key) is None: + data[key] = value self.subreddit._reddit.post(url, data=data) @@ -1586,7 +1610,6 @@ class SubredditLinkFlairTemplates(SubredditFlairTemplates): for template in reddit.subreddit('NAME').flair.link_templates: print(template) - """ url = API_PATH["link_flair"].format(subreddit=self.subreddit) for template in self.subreddit._reddit.get(url):
praw-dev/praw
428ca8ff0ad1ef0f5ab58ef423dac16fb0e2b9c3
diff --git a/tests/integration/cassettes/TestSubredditFlairTemplates.test_update.json b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update.json index 7eda9564..98a62ff4 100644 --- a/tests/integration/cassettes/TestSubredditFlairTemplates.test_update.json +++ b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update.json @@ -1,7 +1,7 @@ { "http_interactions": [ { - "recorded_at": "2019-07-22T14:25:22", + "recorded_at": "2020-01-18T03:20:47", "request": { "body": { "encoding": "utf-8", @@ -21,13 +21,13 @@ "keep-alive" ], "Content-Length": [ - "56" + "61" ], "Content-Type": [ "application/x-www-form-urlencoded" ], "User-Agent": [ - "<USER_AGENT> PRAW/6.3.2.dev0 prawcore/1.0.1" + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" ] }, "method": "POST", @@ -46,19 +46,19 @@ "keep-alive" ], "Content-Length": [ - "117" + "118" ], "Content-Type": [ "application/json; charset=UTF-8" ], "Date": [ - "Mon, 22 Jul 2019 14:25:22 GMT" + "Sat, 18 Jan 2020 03:20:47 GMT" ], "Server": [ "snooserv" ], "Set-Cookie": [ - "edgebucket=pT8rCAvopyQy1YAG6Y; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + "edgebucket=if98uHniIaW8uApc9b; Domain=reddit.com; Max-Age=63071999; Path=/; secure" ], "Strict-Transport-Security": [ "max-age=15552000; includeSubDomains; preload" @@ -76,10 +76,10 @@ "majestic" ], "X-Served-By": [ - "cache-mel19034-MEL" + "cache-lga21981-LGA" ], "X-Timer": [ - "S1563805522.845840,VS0,VE589" + "S1579317647.919862,VS0,VE293" ], "cache-control": [ "max-age=0, must-revalidate" @@ -102,7 +102,7 @@ } }, { - "recorded_at": "2019-07-22T14:25:23", + "recorded_at": "2020-01-18T03:20:47", "request": { "body": { "encoding": "utf-8", @@ -122,10 +122,10 @@ "keep-alive" ], "Cookie": [ - "edgebucket=pT8rCAvopyQy1YAG6Y" + "edgebucket=if98uHniIaW8uApc9b" ], "User-Agent": [ - "<USER_AGENT> PRAW/6.3.2.dev0 prawcore/1.0.1" + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" ] }, "method": "GET", @@ -134,7 +134,7 @@ "response": { "body": { "encoding": "UTF-8", - "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"91cea324-aba5-11e9-af49-0ef93a22fa32\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"Rambunctious34\", \"text_color\": \"dark\", \"mod_only\": true, \"background_color\": \"#72845a\", \"id\": \"67c3e878-ac54-11e9-a6f6-0e97d1593498\", \"css_class\": \"ASfdzA\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"Rambunctious3\", \"text_color\": \"light\", \"mod_only\": true, \"background_color\": \"\", \"id\": \"278aafa6-ac7e-11e9-b0aa-0eeeac23f588\", \"css_class\": \"ASfdzA\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}]" + "string": "[{\"allowable_content\": \"all\", \"text\": \"Text\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"Test\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Text\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" }, "headers": { "Accept-Ranges": [ @@ -144,13 +144,13 @@ "keep-alive" ], "Content-Length": [ - "870" + "4512" ], "Content-Type": [ "application/json; charset=UTF-8" ], "Date": [ - "Mon, 22 Jul 2019 14:25:23 GMT" + "Sat, 18 Jan 2020 03:20:47 GMT" ], "Server": [ "snooserv" @@ -174,21 +174,20 @@ "majestic" ], "X-Served-By": [ - "cache-mel19021-MEL" + "cache-lga21946-LGA" ], "X-Timer": [ - "S1563805523.645013,VS0,VE1074" + "S1579317647.476758,VS0,VE128" ], "cache-control": [ - "private, s-maxage=0, max-age=0, must-revalidate, max-age=0, must-revalidate" + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" ], "expires": [ "-1" ], "set-cookie": [ - "loid=000000000004x25quk.2.1498230528268.Z0FBQUFBQmROY2RUYl9DVDdwQ2YybnpGX3BfQVhWMUIzVmx1MWI2RUlrTjlCaFlfT2lWUlZoZTNESjF5MkVCaGY0Q0FicGRhSGYxeWFUZ2dYNzBVX0tGbjB6cF9NY1lXM1lIdHU4R045UWhqUnFlc2ZfcWJpR2NqeXpfUmZHOV9lT1BzUnZiR3RXNEw; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Wed, 21-Jul-2021 14:25:23 GMT; secure", - "redesign_optout=true; Domain=reddit.com; Max-Age=94607999; Path=/; expires=Thu, 21-Jul-2022 14:25:23 GMT; secure", - "session_tracker=cQOGwd2d7K9ncQTSCz.0.1563805523448.Z0FBQUFBQmROY2RURm9QdUNHR3ZUQ1FRRC1VbDJSTVU3a2hIQ2xlbkJuOEt1MmdNTUFHRzN6Q05uTW1SUXBDcnBtLTlfV2N1LWd5VzVaUU9EdngxS1RCSnBmLTczanlyd0pqLVdZV0tuS2lWa2ZvYUFmbE9xQUpMb3p5MjA1dG03Wl9GdWs4SEY2Ulk; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 22-Jul-2019 16:25:23 GMT; secure" + "loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVJbm1QOHB0QXUzWUd2cDA4ckVUbk5xOS0wdnZWVmFWREh4dlZROHY0TTA3VUVQWTlmZnBReUw4a1U3S2d5bVFacnFpM2M0SkdBU3M3NzZrNVVGa0xiZEZHY3lLY1JwUjdyTE1oREtUZ21UZkRmWUFFeWVub3NzNUZ5cGRuWDJJWnpQUDg; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Mon, 17-Jan-2022 03:20:47 GMT; secure", + "session_tracker=XJflmBlccWJEeiqoqx.0.1579317647504.Z0FBQUFBQmVJbm1QU3R1WEs2c3AtNnR0UVZnT0JWVm0xV0pjbS11UndYMUhOX2U5SDNMcTJBZ3VnNWtnT1p1SDBVYV9YTHBxSkgxem0xTDV2MjdrOFg4Nm5sYXN1ZE9kQjVTNllaaFdOSndZR29ZWUJDMWV0LUsxNzVzN0dXOGlPUUdZc3JzaUxjblM; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 18-Jan-2020 05:20:47 GMT; secure" ], "x-content-type-options": [ "nosniff" @@ -197,13 +196,13 @@ "SAMEORIGIN" ], "x-ratelimit-remaining": [ - "597.0" + "599.0" ], "x-ratelimit-reset": [ - "277" + "553" ], "x-ratelimit-used": [ - "3" + "1" ], "x-ua-compatible": [ "IE=edge" @@ -220,11 +219,11 @@ } }, { - "recorded_at": "2019-07-22T14:25:24", + "recorded_at": "2020-01-18T03:20:47", "request": { "body": { "encoding": "utf-8", - "string": "api_type=json&background_color=%2300FFFF&css_class=myCSS&flair_template_id=91cea324-aba5-11e9-af49-0ef93a22fa32&text=PRAW+updated&text_color=dark&text_editable=False" + "string": "" }, "headers": { "Accept": [ @@ -239,17 +238,133 @@ "Connection": [ "keep-alive" ], + "Cookie": [ + "edgebucket=if98uHniIaW8uApc9b; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVJbm1QOHB0QXUzWUd2cDA4ckVUbk5xOS0wdnZWVmFWREh4dlZROHY0TTA3VUVQWTlmZnBReUw4a1U3S2d5bVFacnFpM2M0SkdBU3M3NzZrNVVGa0xiZEZHY3lLY1JwUjdyTE1oREtUZ21UZkRmWUFFeWVub3NzNUZ5cGRuWDJJWnpQUDg; session_tracker=XJflmBlccWJEeiqoqx.0.1579317647504.Z0FBQUFBQmVJbm1QU3R1WEs2c3AtNnR0UVZnT0JWVm0xV0pjbS11UndYMUhOX2U5SDNMcTJBZ3VnNWtnT1p1SDBVYV9YTHBxSkgxem0xTDV2MjdrOFg4Nm5sYXN1ZE9kQjVTNllaaFdOSndZR29ZWUJDMWV0LUsxNzVzN0dXOGlPUUdZc3JzaUxjblM" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"Text\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"Test\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Text\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], "Content-Length": [ - "165" + "4512" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 18 Jan 2020 03:20:47 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21946-LGA" + ], + "X-Timer": [ + "S1579317648.632684,VS0,VE118" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=XJflmBlccWJEeiqoqx.0.1579317647664.Z0FBQUFBQmVJbm1QV3BSV2FXekFoWU1fTnVvdWhxRzBXczdjV0VRdnFnVHgxdndKT0VsTXpfazFtTk5MRnlMUlkxYmg3UlRkSXRWTkc2MDI0N1VIZE1KQUZJWmQzSVVzcTRBT18xdUNQX2hMQy1ZRXBqR0lRTjdiaHd4MDZlcENlZDc2MlB5UGpxcHA; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 18-Jan-2020 05:20:47 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "598.0" + ], + "x-ratelimit-reset": [ + "553" + ], + "x-ratelimit-used": [ + "2" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + } + }, + { + "recorded_at": "2020-01-18T03:20:47", + "request": { + "body": { + "encoding": "utf-8", + "string": "allowable_content=all&api_type=json&background_color=%2300FFFF&css_class=myCSS&flair_template_id=488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf&max_emojis=10&mod_only=False&text=PRAW+updated&text_color=dark&text_editable=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "216" ], "Content-Type": [ "application/x-www-form-urlencoded" ], "Cookie": [ - "edgebucket=pT8rCAvopyQy1YAG6Y; loid=000000000004x25quk.2.1498230528268.Z0FBQUFBQmROY2RUYl9DVDdwQ2YybnpGX3BfQVhWMUIzVmx1MWI2RUlrTjlCaFlfT2lWUlZoZTNESjF5MkVCaGY0Q0FicGRhSGYxeWFUZ2dYNzBVX0tGbjB6cF9NY1lXM1lIdHU4R045UWhqUnFlc2ZfcWJpR2NqeXpfUmZHOV9lT1BzUnZiR3RXNEw; redesign_optout=true; session_tracker=cQOGwd2d7K9ncQTSCz.0.1563805523448.Z0FBQUFBQmROY2RURm9QdUNHR3ZUQ1FRRC1VbDJSTVU3a2hIQ2xlbkJuOEt1MmdNTUFHRzN6Q05uTW1SUXBDcnBtLTlfV2N1LWd5VzVaUU9EdngxS1RCSnBmLTczanlyd0pqLVdZV0tuS2lWa2ZvYUFmbE9xQUpMb3p5MjA1dG03Wl9GdWs4SEY2Ulk" + "edgebucket=if98uHniIaW8uApc9b; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVJbm1QOHB0QXUzWUd2cDA4ckVUbk5xOS0wdnZWVmFWREh4dlZROHY0TTA3VUVQWTlmZnBReUw4a1U3S2d5bVFacnFpM2M0SkdBU3M3NzZrNVVGa0xiZEZHY3lLY1JwUjdyTE1oREtUZ21UZkRmWUFFeWVub3NzNUZ5cGRuWDJJWnpQUDg; session_tracker=XJflmBlccWJEeiqoqx.0.1579317647664.Z0FBQUFBQmVJbm1QV3BSV2FXekFoWU1fTnVvdWhxRzBXczdjV0VRdnFnVHgxdndKT0VsTXpfazFtTk5MRnlMUlkxYmg3UlRkSXRWTkc2MDI0N1VIZE1KQUZJWmQzSVVzcTRBT18xdUNQX2hMQy1ZRXBqR0lRTjdiaHd4MDZlcENlZDc2MlB5UGpxcHA" ], "User-Agent": [ - "<USER_AGENT> PRAW/6.3.2.dev0 prawcore/1.0.1" + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" ] }, "method": "POST", @@ -258,7 +373,7 @@ "response": { "body": { "encoding": "UTF-8", - "string": "{\"text\": \"PRAW updated\", \"allowableContent\": \"all\", \"modOnly\": false, \"cssClass\": \"myCSS\", \"id\": \"91cea324-aba5-11e9-af49-0ef93a22fa32\", \"textEditable\": false, \"overrideCss\": false, \"richtext\": [], \"maxEmojis\": 10, \"flairType\": \"USER_FLAIR\", \"backgroundColor\": \"#00ffff\", \"textColor\": \"dark\", \"type\": \"text\"}" + "string": "{\"text\": \"PRAW updated\", \"allowableContent\": \"all\", \"modOnly\": false, \"cssClass\": \"myCSS\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"textEditable\": false, \"overrideCss\": false, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"maxEmojis\": 10, \"flairType\": \"USER_FLAIR\", \"backgroundColor\": \"#00ffff\", \"textColor\": \"dark\", \"type\": \"richtext\"}" }, "headers": { "Accept-Ranges": [ @@ -268,13 +383,13 @@ "keep-alive" ], "Content-Length": [ - "308" + "346" ], "Content-Type": [ "application/json; charset=UTF-8" ], "Date": [ - "Mon, 22 Jul 2019 14:25:24 GMT" + "Sat, 18 Jan 2020 03:20:47 GMT" ], "Server": [ "snooserv" @@ -295,19 +410,19 @@ "majestic" ], "X-Served-By": [ - "cache-mel19021-MEL" + "cache-lga21946-LGA" ], "X-Timer": [ - "S1563805524.776659,VS0,VE372" + "S1579317648.778265,VS0,VE132" ], "cache-control": [ - "private, s-maxage=0, max-age=0, must-revalidate, max-age=0, must-revalidate" + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" ], "expires": [ "-1" ], "set-cookie": [ - "session_tracker=cQOGwd2d7K9ncQTSCz.0.1563805523924.Z0FBQUFBQmROY2RVcWtOaDNHYkFJU09XaC1vVTUzcEF2R2l0T1BxQ01PQk50TUNCa1hnWl82QTlXZHV4Z1VXcFFWelVwMGdrRWZrTndYazE5RnBCeW9keWlwUzluM0QzaFBxa05BNnJTaHV5ZndROU1zM0t3a1BBNThWUUNOYzlsREN0ZjhfZ0FnY2w; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 22-Jul-2019 16:25:24 GMT; secure" + "session_tracker=XJflmBlccWJEeiqoqx.0.1579317647805.Z0FBQUFBQmVJbm1QQkd2TWRCZzZMdFBTRW9JbVdISVRRN2VTNG9YX3JNUGsxenE4SzhfSmVnN1Y5TlBpa1NlWTNuVWZRc2tyQThZTHB6a1dMUmNlY2RselM2dmx6VE8xVHMtVHZBMmRuc0owOGluQnNyb21tS0dZbHFMbnlUelBWck0wUTJVZjQyalc; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 18-Jan-2020 05:20:47 GMT; secure" ], "x-content-type-options": [ "nosniff" @@ -316,13 +431,13 @@ "SAMEORIGIN" ], "x-ratelimit-remaining": [ - "596.0" + "597.0" ], "x-ratelimit-reset": [ - "277" + "553" ], "x-ratelimit-used": [ - "4" + "3" ], "x-ua-compatible": [ "IE=edge" diff --git a/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_false.json b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_false.json new file mode 100644 index 00000000..876edd07 --- /dev/null +++ b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_false.json @@ -0,0 +1,809 @@ +{ + "http_interactions": [ + { + "recorded_at": "2020-01-30T01:20:16", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=<PASSWORD>&username=<USERNAME>" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic <BASIC_AUTH>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "61" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/7.0.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Thu, 30 Jan 2020 01:20:16 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=ABDD1v14tybmA3vOZv; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21952-LGA" + ], + "X-Timer": [ + "S1580347216.132303,VS0,VE308" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2020-01-30T01:20:16", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=ABDD1v14tybmA3vOZv" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/7.0.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"fdd612e4-3b0d-11ea-9392-0e87026a9dfd\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"8d42a7ec-3b10-11ea-aa60-0ec419547aa7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"9888b31c-3b10-11ea-ba79-0e8eeb7625d9\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"d564a2b4-3b10-11ea-9c27-0e38b4413acd\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"11b600fa-3b11-11ea-9965-0ede2116dd5f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"2654bdee-3b11-11ea-be6e-0e368dee9941\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "6200" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Thu, 30 Jan 2020 01:20:16 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21977-LGA" + ], + "X-Timer": [ + "S1580347217.685302,VS0,VE133" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVNaTlRTXUtS09zc292TGF4NFlPY2tKRjJuellQZGU1aEJvWWxNQ0xOQlhYVzZZUWNOUXpNUFFQTHFOWURFeGtad1F2VEt2ODZaVnp2WlNXOTVlN044WjNPREVBZ0w3dDUtOC1CT2RHQjhOeF9uRDRNZExpdlVJOEc0cWhZN3QxWUQ1RGI; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Sat, 29-Jan-2022 01:20:16 GMT; secure", + "session_tracker=DWVxZHTUOlQNIwFoO4.0.1580347216718.Z0FBQUFBQmVNaTlRVnduZnR6a0Z5aW04ajVOelQ4ZTBnTkRmbkI3Nm1RaHJJRldzNkNwN3BEbVhFSzNSMmo0bFJVRUpxMXVIcnl6c280Q0gxRFBheW1hMzM4Y3FXZDk1M1ZKSjBOc0g5SU8xd3BDT3FTSHdUNFlYbk5LRlpaOHhCM2FVNnFETEp2YlE; Domain=reddit.com; Max-Age=7199; Path=/; expires=Thu, 30-Jan-2020 03:20:16 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "599.0" + ], + "x-ratelimit-reset": [ + "584" + ], + "x-ratelimit-used": [ + "1" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + } + }, + { + "recorded_at": "2020-01-30T01:20:16", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=ABDD1v14tybmA3vOZv; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVNaTlRTXUtS09zc292TGF4NFlPY2tKRjJuellQZGU1aEJvWWxNQ0xOQlhYVzZZUWNOUXpNUFFQTHFOWURFeGtad1F2VEt2ODZaVnp2WlNXOTVlN044WjNPREVBZ0w3dDUtOC1CT2RHQjhOeF9uRDRNZExpdlVJOEc0cWhZN3QxWUQ1RGI; session_tracker=DWVxZHTUOlQNIwFoO4.0.1580347216718.Z0FBQUFBQmVNaTlRVnduZnR6a0Z5aW04ajVOelQ4ZTBnTkRmbkI3Nm1RaHJJRldzNkNwN3BEbVhFSzNSMmo0bFJVRUpxMXVIcnl6c280Q0gxRFBheW1hMzM4Y3FXZDk1M1ZKSjBOc0g5SU8xd3BDT3FTSHdUNFlYbk5LRlpaOHhCM2FVNnFETEp2YlE" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/7.0.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"fdd612e4-3b0d-11ea-9392-0e87026a9dfd\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"8d42a7ec-3b10-11ea-aa60-0ec419547aa7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"9888b31c-3b10-11ea-ba79-0e8eeb7625d9\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"d564a2b4-3b10-11ea-9c27-0e38b4413acd\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"11b600fa-3b11-11ea-9965-0ede2116dd5f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"2654bdee-3b11-11ea-be6e-0e368dee9941\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "6200" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Thu, 30 Jan 2020 01:20:16 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21977-LGA" + ], + "X-Timer": [ + "S1580347217.872059,VS0,VE118" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=DWVxZHTUOlQNIwFoO4.0.1580347216913.Z0FBQUFBQmVNaTlRT0dpS3QxTVNCbmVKVEl3Y0JkNkwzVlpnN1FkTFNsVEJuVExyQ3M2Z1Q2cTlpemkyM1R0NVgwSnhhSDJkQ0R5UXpLaV9NNlFEVndTSVdIbUx1c1lVdE9Hd1haV29yS0Q1VGJGLWM0QjhvbGVGS3RJdlVtdFBzVU1RalBEa1IzNzk; Domain=reddit.com; Max-Age=7199; Path=/; expires=Thu, 30-Jan-2020 03:20:16 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "598.0" + ], + "x-ratelimit-reset": [ + "584" + ], + "x-ratelimit-used": [ + "2" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + } + }, + { + "recorded_at": "2020-01-30T01:20:17", + "request": { + "body": { + "encoding": "utf-8", + "string": "allowable_content=all&api_type=json&background_color=%2300ffff&css_class=myCSS&flair_template_id=488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf&id=488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf&max_emojis=10&mod_only=False&override_css=False&richtext=e&richtext=t&text=PRAW+updated&text_color=dark&text_editable=False&type=richtext" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "311" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=ABDD1v14tybmA3vOZv; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVNaTlRTXUtS09zc292TGF4NFlPY2tKRjJuellQZGU1aEJvWWxNQ0xOQlhYVzZZUWNOUXpNUFFQTHFOWURFeGtad1F2VEt2ODZaVnp2WlNXOTVlN044WjNPREVBZ0w3dDUtOC1CT2RHQjhOeF9uRDRNZExpdlVJOEc0cWhZN3QxWUQ1RGI; session_tracker=DWVxZHTUOlQNIwFoO4.0.1580347216913.Z0FBQUFBQmVNaTlRT0dpS3QxTVNCbmVKVEl3Y0JkNkwzVlpnN1FkTFNsVEJuVExyQ3M2Z1Q2cTlpemkyM1R0NVgwSnhhSDJkQ0R5UXpLaV9NNlFEVndTSVdIbUx1c1lVdE9Hd1haV29yS0Q1VGJGLWM0QjhvbGVGS3RJdlVtdFBzVU1RalBEa1IzNzk" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/7.0.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"text\": \"PRAW updated\", \"allowableContent\": \"all\", \"modOnly\": false, \"cssClass\": \"myCSS\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"textEditable\": false, \"overrideCss\": false, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"maxEmojis\": 10, \"flairType\": \"USER_FLAIR\", \"backgroundColor\": \"#00ffff\", \"textColor\": \"dark\", \"type\": \"richtext\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "346" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Thu, 30 Jan 2020 01:20:17 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21977-LGA" + ], + "X-Timer": [ + "S1580347217.032147,VS0,VE147" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=DWVxZHTUOlQNIwFoO4.0.1580347217060.Z0FBQUFBQmVNaTlSTmZMT014aG5hd0lGWHFCVDBVYmVvZm5PejJjTnc2MDZiZG93bnIzTldaazk2TXJKaUc3aHFCZGduNkxZSWhUNFNhSkJtR0xtMjVQSnF5UXBSOF9sOW9LSnQzbXY5dEl2SW44Zy0tMy1Ta1BQMmRjUUFkc0g5WTR1bXFpUDgwa3I; Domain=reddit.com; Max-Age=7199; Path=/; expires=Thu, 30-Jan-2020 03:20:17 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "597.0" + ], + "x-ratelimit-reset": [ + "583" + ], + "x-ratelimit-used": [ + "3" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + } + }, + { + "recorded_at": "2020-01-30T01:20:17", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=ABDD1v14tybmA3vOZv; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVNaTlRTXUtS09zc292TGF4NFlPY2tKRjJuellQZGU1aEJvWWxNQ0xOQlhYVzZZUWNOUXpNUFFQTHFOWURFeGtad1F2VEt2ODZaVnp2WlNXOTVlN044WjNPREVBZ0w3dDUtOC1CT2RHQjhOeF9uRDRNZExpdlVJOEc0cWhZN3QxWUQ1RGI; session_tracker=DWVxZHTUOlQNIwFoO4.0.1580347217060.Z0FBQUFBQmVNaTlSTmZMT014aG5hd0lGWHFCVDBVYmVvZm5PejJjTnc2MDZiZG93bnIzTldaazk2TXJKaUc3aHFCZGduNkxZSWhUNFNhSkJtR0xtMjVQSnF5UXBSOF9sOW9LSnQzbXY5dEl2SW44Zy0tMy1Ta1BQMmRjUUFkc0g5WTR1bXFpUDgwa3I" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/7.0.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=2&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"fdd612e4-3b0d-11ea-9392-0e87026a9dfd\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"8d42a7ec-3b10-11ea-aa60-0ec419547aa7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"9888b31c-3b10-11ea-ba79-0e8eeb7625d9\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"d564a2b4-3b10-11ea-9c27-0e38b4413acd\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"11b600fa-3b11-11ea-9965-0ede2116dd5f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"2654bdee-3b11-11ea-be6e-0e368dee9941\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "6200" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Thu, 30 Jan 2020 01:20:17 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21977-LGA" + ], + "X-Timer": [ + "S1580347217.201486,VS0,VE78" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=DWVxZHTUOlQNIwFoO4.0.1580347217229.Z0FBQUFBQmVNaTlSMmYtWUNEWDZuWTl2eDBRS05yajJNYkdJeTkzcElLZlVVcWhzUUlSN1FSNFBZc1hmclFpNGNRQkV5a2RPX0ZUWXV4dTBPUElPRXhrTkdXdkZ0U21kcV8tMWJuZXZZYW42RkRGNm9IbFc1MXJHRUxNVlVmRzF3ZHdCTFV0eDhIUXA; Domain=reddit.com; Max-Age=7199; Path=/; expires=Thu, 30-Jan-2020 03:20:17 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "596.0" + ], + "x-ratelimit-reset": [ + "583" + ], + "x-ratelimit-used": [ + "4" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=2&raw_json=1" + } + }, + { + "recorded_at": "2020-01-30T01:20:17", + "request": { + "body": { + "encoding": "utf-8", + "string": "allowable_content=all&api_type=json&background_color=%2300ffff&css_class=myCSS&flair_template_id=488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf&id=488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf&max_emojis=10&mod_only=False&override_css=False&richtext=e&richtext=t&text=PRAW+updated&text_color=dark&text_editable=False&type=richtext" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "311" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=ABDD1v14tybmA3vOZv; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVNaTlRTXUtS09zc292TGF4NFlPY2tKRjJuellQZGU1aEJvWWxNQ0xOQlhYVzZZUWNOUXpNUFFQTHFOWURFeGtad1F2VEt2ODZaVnp2WlNXOTVlN044WjNPREVBZ0w3dDUtOC1CT2RHQjhOeF9uRDRNZExpdlVJOEc0cWhZN3QxWUQ1RGI; session_tracker=DWVxZHTUOlQNIwFoO4.0.1580347217229.Z0FBQUFBQmVNaTlSMmYtWUNEWDZuWTl2eDBRS05yajJNYkdJeTkzcElLZlVVcWhzUUlSN1FSNFBZc1hmclFpNGNRQkV5a2RPX0ZUWXV4dTBPUElPRXhrTkdXdkZ0U21kcV8tMWJuZXZZYW42RkRGNm9IbFc1MXJHRUxNVlVmRzF3ZHdCTFV0eDhIUXA" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/7.0.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"text\": \"PRAW updated\", \"allowableContent\": \"all\", \"modOnly\": false, \"cssClass\": \"myCSS\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"textEditable\": false, \"overrideCss\": false, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"maxEmojis\": 10, \"flairType\": \"USER_FLAIR\", \"backgroundColor\": \"#00ffff\", \"textColor\": \"dark\", \"type\": \"richtext\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "346" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Thu, 30 Jan 2020 01:20:17 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21977-LGA" + ], + "X-Timer": [ + "S1580347217.309721,VS0,VE141" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=DWVxZHTUOlQNIwFoO4.0.1580347217337.Z0FBQUFBQmVNaTlSZDhKcTdMNjJVLVBLbU5IYkkyUkpKZkgtRmV4ZmVBV1gxb1NOSTlNekxCbjlUd2RBT3dQRU5ZN242akxyaGVSUDVNd0pEdWhJYTBTVWE5dHNrb0JKeFpQNzl0TWU0NkpQSEdjd0xETWZfSjR1NXB4RHFBdXZLQ3FDTnRpYTBKaVA; Domain=reddit.com; Max-Age=7199; Path=/; expires=Thu, 30-Jan-2020 03:20:17 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "595.0" + ], + "x-ratelimit-reset": [ + "583" + ], + "x-ratelimit-used": [ + "5" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + } + }, + { + "recorded_at": "2020-01-30T01:20:17", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=ABDD1v14tybmA3vOZv; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVNaTlRTXUtS09zc292TGF4NFlPY2tKRjJuellQZGU1aEJvWWxNQ0xOQlhYVzZZUWNOUXpNUFFQTHFOWURFeGtad1F2VEt2ODZaVnp2WlNXOTVlN044WjNPREVBZ0w3dDUtOC1CT2RHQjhOeF9uRDRNZExpdlVJOEc0cWhZN3QxWUQ1RGI; session_tracker=DWVxZHTUOlQNIwFoO4.0.1580347217337.Z0FBQUFBQmVNaTlSZDhKcTdMNjJVLVBLbU5IYkkyUkpKZkgtRmV4ZmVBV1gxb1NOSTlNekxCbjlUd2RBT3dQRU5ZN242akxyaGVSUDVNd0pEdWhJYTBTVWE5dHNrb0JKeFpQNzl0TWU0NkpQSEdjd0xETWZfSjR1NXB4RHFBdXZLQ3FDTnRpYTBKaVA" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/7.0.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=3&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"fdd612e4-3b0d-11ea-9392-0e87026a9dfd\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"8d42a7ec-3b10-11ea-aa60-0ec419547aa7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"9888b31c-3b10-11ea-ba79-0e8eeb7625d9\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"d564a2b4-3b10-11ea-9c27-0e38b4413acd\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"11b600fa-3b11-11ea-9965-0ede2116dd5f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"2654bdee-3b11-11ea-be6e-0e368dee9941\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "6200" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Thu, 30 Jan 2020 01:20:17 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21977-LGA" + ], + "X-Timer": [ + "S1580347217.471329,VS0,VE113" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=DWVxZHTUOlQNIwFoO4.0.1580347217508.Z0FBQUFBQmVNaTlSWnFEOElFb1dyRW1NRTB1MW9DaFlJeEJaZi0wY2h6RVNZYjg1bkZoZFpUY0lCbnIzeFhXZll1S1ZRaW1LSXlwT2lsNmJfY2IwV3pfSWlXVEhCRUsxYmpFWlNEUUw0Qk1KMkxHWjR4cVFMNE93d05la1IwaUwxLVpwYmluQ0RvaTY; Domain=reddit.com; Max-Age=7199; Path=/; expires=Thu, 30-Jan-2020 03:20:17 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "594.0" + ], + "x-ratelimit-reset": [ + "583" + ], + "x-ratelimit-used": [ + "6" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=3&raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch.json b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch.json new file mode 100644 index 00000000..03470185 --- /dev/null +++ b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch.json @@ -0,0 +1,458 @@ +{ + "http_interactions": [ + { + "recorded_at": "2020-01-19T22:48:45", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=<PASSWORD>&username=<USERNAME>" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic <BASIC_AUTH>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "61" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:45 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=rHUMh3L0SQhCm0YV17; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21938-LGA" + ], + "X-Timer": [ + "S1579474125.732064,VS0,VE308" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2020-01-19T22:48:45", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=rHUMh3L0SQhCm0YV17" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "4536" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:45 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21973-LGA" + ], + "X-Timer": [ + "S1579474125.251501,VS0,VE125" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpObE1STGxhaUw4RFZpb0V6SjFTR1RHQUdISlkxUXdzQTdMLTJMenlHN3NQZFpzbzRiS182a3F5VkJuUC1rdWxtY0R3Y3YwelB2WW5uMXpqbVY3b19RUlRrNi0zY3kxYTNoWmUyRnpORmNwd2dVaDE4ck9yWC1tTGpEYVoySXVJdFQ; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 18-Jan-2022 22:48:45 GMT; secure", + "session_tracker=ZmVCLN1WSjZkdIjIC7.0.1579474125279.Z0FBQUFBQmVKTnpOTUsxclFPb0t2Y0k3YkZEZ3ozSTNzQk82a1N3VVBzT25tdE9aX21ha3psVXVoS19DdkVXbWE2dTNiNktUMGJsaXNMOUttY2ZCVzl4b1hya3RWV0hfQjZoWnB5X25KZW9xZEltVUM1WEV0VkZ5cTBfZE9IdDFrSWNYakhSMWNiQ1c; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:45 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "599.0" + ], + "x-ratelimit-reset": [ + "75" + ], + "x-ratelimit-used": [ + "1" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + } + }, + { + "recorded_at": "2020-01-19T22:48:45", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=rHUMh3L0SQhCm0YV17; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpObE1STGxhaUw4RFZpb0V6SjFTR1RHQUdISlkxUXdzQTdMLTJMenlHN3NQZFpzbzRiS182a3F5VkJuUC1rdWxtY0R3Y3YwelB2WW5uMXpqbVY3b19RUlRrNi0zY3kxYTNoWmUyRnpORmNwd2dVaDE4ck9yWC1tTGpEYVoySXVJdFQ; session_tracker=ZmVCLN1WSjZkdIjIC7.0.1579474125279.Z0FBQUFBQmVKTnpOTUsxclFPb0t2Y0k3YkZEZ3ozSTNzQk82a1N3VVBzT25tdE9aX21ha3psVXVoS19DdkVXbWE2dTNiNktUMGJsaXNMOUttY2ZCVzl4b1hya3RWV0hfQjZoWnB5X25KZW9xZEltVUM1WEV0VkZ5cTBfZE9IdDFrSWNYakhSMWNiQ1c" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "4536" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:45 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21973-LGA" + ], + "X-Timer": [ + "S1579474125.408452,VS0,VE151" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=ZmVCLN1WSjZkdIjIC7.0.1579474125467.Z0FBQUFBQmVKTnpObjYwVTd0bjY5QTE5ajJnSlh1RFVKbmNNNWl4a040RTk1X25OcW9sLXJ6blFKeUFib2Q2NXhKZWJCQVZSNE9NbWFEdVY5aXdyQUNqM05qSGdJaVBtZ09hbkdYeE80R0xYQWszRmNvWS1sOHI0V2VwbElRbU43TVBkUUxUbFl2QUw; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:45 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "598.0" + ], + "x-ratelimit-reset": [ + "75" + ], + "x-ratelimit-used": [ + "2" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + } + }, + { + "recorded_at": "2020-01-19T22:48:45", + "request": { + "body": { + "encoding": "utf-8", + "string": "allowable_content=all&api_type=json&background_color=%2300FFFF&css_class=myCSS&flair_template_id=488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf&max_emojis=10&mod_only=False&text=PRAW+updated&text_color=dark&text_editable=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "216" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=rHUMh3L0SQhCm0YV17; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpObE1STGxhaUw4RFZpb0V6SjFTR1RHQUdISlkxUXdzQTdMLTJMenlHN3NQZFpzbzRiS182a3F5VkJuUC1rdWxtY0R3Y3YwelB2WW5uMXpqbVY3b19RUlRrNi0zY3kxYTNoWmUyRnpORmNwd2dVaDE4ck9yWC1tTGpEYVoySXVJdFQ; session_tracker=ZmVCLN1WSjZkdIjIC7.0.1579474125467.Z0FBQUFBQmVKTnpObjYwVTd0bjY5QTE5ajJnSlh1RFVKbmNNNWl4a040RTk1X25OcW9sLXJ6blFKeUFib2Q2NXhKZWJCQVZSNE9NbWFEdVY5aXdyQUNqM05qSGdJaVBtZ09hbkdYeE80R0xYQWszRmNvWS1sOHI0V2VwbElRbU43TVBkUUxUbFl2QUw" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"text\": \"PRAW updated\", \"allowableContent\": \"all\", \"modOnly\": false, \"cssClass\": \"myCSS\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"textEditable\": false, \"overrideCss\": false, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"maxEmojis\": 10, \"flairType\": \"USER_FLAIR\", \"backgroundColor\": \"#00ffff\", \"textColor\": \"dark\", \"type\": \"richtext\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "346" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:45 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21973-LGA" + ], + "X-Timer": [ + "S1579474126.589302,VS0,VE183" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=ZmVCLN1WSjZkdIjIC7.0.1579474125661.Z0FBQUFBQmVKTnpOc2tZRzJVVTJpYm1HWWNwTG9weWFpcjF0bWlvaE5HS1p0a2E2d3lKaTItamlVbnZHNzV0RmNDRk1xYk9Kelp3TWROYUVrRzRYSlhLS0w4UG9uMWhKblQ3QmE5WjBiWVBkam9OREJiR2s4eHgyYzhVZm5IT1hZUG13Ung2VHpudzk; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:45 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "597.0" + ], + "x-ratelimit-reset": [ + "75" + ], + "x-ratelimit-used": [ + "3" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_no_css_class.json b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_no_css_class.json new file mode 100644 index 00000000..e763ab7c --- /dev/null +++ b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_no_css_class.json @@ -0,0 +1,458 @@ +{ + "http_interactions": [ + { + "recorded_at": "2020-01-19T22:48:46", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=<PASSWORD>&username=<USERNAME>" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic <BASIC_AUTH>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "61" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:46 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=UQBMKrtrwUHGbY2jOg; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21928-LGA" + ], + "X-Timer": [ + "S1579474126.152422,VS0,VE293" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2020-01-19T22:48:46", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=UQBMKrtrwUHGbY2jOg" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "4536" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:46 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21973-LGA" + ], + "X-Timer": [ + "S1579474127.728064,VS0,VE155" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpPb0hMT0FwS0ZqOGJkVXpSUjNVekcxYnpZbzdDZDlxMWRHMG5nUmF6c0k5djBrUDNIZXZkR3I5UEFLUGJhdXN4NUpTQUlwdnZqWEpxWWJjT1REcW9oaEdTcTZSMTNCN2NJam5UR0h4Q1M1SVg5ZjdkRVFsZWg0TnhMa2RFMG92eTA; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 18-Jan-2022 22:48:46 GMT; secure", + "session_tracker=lu8PqMxx5JdsMIgFs8.0.1579474126762.Z0FBQUFBQmVKTnpPaGkxSFBNTWpPQmhhbWNHVFVNM2VHTVplSE5fdFFDOXJKZEU1Zzlfc1hwY05hb0hqV2JTSGZ0anp0YUVWdVE4U3VfMnRfQXMwQUg5eGhWLTNvRk9hRGE3QnlVZFFQMmxaUGw4OE5ySUd1aFFzLVJ6bkRsUF9LNmRIQ1U1ODFjODY; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:46 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "596.0" + ], + "x-ratelimit-reset": [ + "74" + ], + "x-ratelimit-used": [ + "4" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + } + }, + { + "recorded_at": "2020-01-19T22:48:47", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=UQBMKrtrwUHGbY2jOg; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpPb0hMT0FwS0ZqOGJkVXpSUjNVekcxYnpZbzdDZDlxMWRHMG5nUmF6c0k5djBrUDNIZXZkR3I5UEFLUGJhdXN4NUpTQUlwdnZqWEpxWWJjT1REcW9oaEdTcTZSMTNCN2NJam5UR0h4Q1M1SVg5ZjdkRVFsZWg0TnhMa2RFMG92eTA; session_tracker=lu8PqMxx5JdsMIgFs8.0.1579474126762.Z0FBQUFBQmVKTnpPaGkxSFBNTWpPQmhhbWNHVFVNM2VHTVplSE5fdFFDOXJKZEU1Zzlfc1hwY05hb0hqV2JTSGZ0anp0YUVWdVE4U3VfMnRfQXMwQUg5eGhWLTNvRk9hRGE3QnlVZFFQMmxaUGw4OE5ySUd1aFFzLVJ6bkRsUF9LNmRIQ1U1ODFjODY" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "4536" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:47 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21973-LGA" + ], + "X-Timer": [ + "S1579474127.909158,VS0,VE135" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=lu8PqMxx5JdsMIgFs8.0.1579474126965.Z0FBQUFBQmVKTnpQNGN6VHNPMG83cW03TEZ2aVl2YzdYdWZxbVZBNjVXUEROY2pvTGRCdl9VbDk0REZyVmdxelA4cUs0RC1JSXUyZ01XLUlnOHdzVjNhMzhsU1FFS1lqTlFYb0UtNXVkRVdCcjdvRzM2bjY5Uk5wc2U2QVBoTlNweFdMTHRyMkNzQW8; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:47 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "595.0" + ], + "x-ratelimit-reset": [ + "74" + ], + "x-ratelimit-used": [ + "5" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + } + }, + { + "recorded_at": "2020-01-19T22:48:47", + "request": { + "body": { + "encoding": "utf-8", + "string": "allowable_content=all&api_type=json&background_color=%2300FFFF&css_class=myCSS&flair_template_id=488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf&max_emojis=10&mod_only=False&text=PRAW+updated&text_color=dark&text_editable=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "216" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=UQBMKrtrwUHGbY2jOg; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpPb0hMT0FwS0ZqOGJkVXpSUjNVekcxYnpZbzdDZDlxMWRHMG5nUmF6c0k5djBrUDNIZXZkR3I5UEFLUGJhdXN4NUpTQUlwdnZqWEpxWWJjT1REcW9oaEdTcTZSMTNCN2NJam5UR0h4Q1M1SVg5ZjdkRVFsZWg0TnhMa2RFMG92eTA; session_tracker=lu8PqMxx5JdsMIgFs8.0.1579474126965.Z0FBQUFBQmVKTnpQNGN6VHNPMG83cW03TEZ2aVl2YzdYdWZxbVZBNjVXUEROY2pvTGRCdl9VbDk0REZyVmdxelA4cUs0RC1JSXUyZ01XLUlnOHdzVjNhMzhsU1FFS1lqTlFYb0UtNXVkRVdCcjdvRzM2bjY5Uk5wc2U2QVBoTlNweFdMTHRyMkNzQW8" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"text\": \"PRAW updated\", \"allowableContent\": \"all\", \"modOnly\": false, \"cssClass\": \"myCSS\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"textEditable\": false, \"overrideCss\": false, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"maxEmojis\": 10, \"flairType\": \"USER_FLAIR\", \"backgroundColor\": \"#00ffff\", \"textColor\": \"dark\", \"type\": \"richtext\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "346" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:47 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21973-LGA" + ], + "X-Timer": [ + "S1579474127.076319,VS0,VE206" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=lu8PqMxx5JdsMIgFs8.0.1579474127120.Z0FBQUFBQmVKTnpQcWs2c1pVZnNlaE0ydE5lWTdmUEZDVGp3WG9JbHhyV1FYYUxwSWJaSkRhOURlSnM5NkFGcl9uVzJvekJxblVnQ1ZOR3gtVDFtUzRnV0hmZ3p5bG03OXNBbmtJZmUwWWpXUXNNb0FJcVozQ0NQVG9OSXU4QXd0SFduRURDeEVwYUU; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:47 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "594.0" + ], + "x-ratelimit-reset": [ + "73" + ], + "x-ratelimit-used": [ + "6" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_no_text.json b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_no_text.json new file mode 100644 index 00000000..10f5d0ce --- /dev/null +++ b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_no_text.json @@ -0,0 +1,458 @@ +{ + "http_interactions": [ + { + "recorded_at": "2020-01-19T22:48:47", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=<PASSWORD>&username=<USERNAME>" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic <BASIC_AUTH>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "61" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:47 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=jLGeRnO8HD6Z9f0tsr; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21938-LGA" + ], + "X-Timer": [ + "S1579474127.476979,VS0,VE347" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2020-01-19T22:48:48", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=jLGeRnO8HD6Z9f0tsr" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "4536" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:48 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21951-LGA" + ], + "X-Timer": [ + "S1579474128.978523,VS0,VE107" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpRQXlwSTF6VDhZMzJlZkF2NDNuVkFwWTk5Q0MzMUkzeFZmdUZZamdHX0JUeHIwd29iSTdEaXNNTG5DeS03YmtFTjg3NWRaMTRrbHQ1cmJGb3lWc1otdG5QWGlQY05rUmtKb0RwWkg0a2ljSHRTS2haZlZJMmxtSnljOG1IMTNxOHg; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 18-Jan-2022 22:48:48 GMT; secure", + "session_tracker=thFScnLWPDid0dKyY1.0.1579474128023.Z0FBQUFBQmVKTnpRdzlkZGpscy1NbVRtRmpBQThvS3NZeXlNeTZYMEdrYjBPeDFlMlJGVHlaZGxTTGNYSC1RVnRla2t1WGJ0aVJ5Z0Rmdks1UHFTc3ROa2tWQ3BmeXVMSUZtMVVRSEdDdXZlQTVDcnNaZmJ1UGdSeWQ3d1RfdmpuU1NvWmtGcFhyRVI; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:48 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "593.0" + ], + "x-ratelimit-reset": [ + "72" + ], + "x-ratelimit-used": [ + "7" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + } + }, + { + "recorded_at": "2020-01-19T22:48:48", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=jLGeRnO8HD6Z9f0tsr; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpRQXlwSTF6VDhZMzJlZkF2NDNuVkFwWTk5Q0MzMUkzeFZmdUZZamdHX0JUeHIwd29iSTdEaXNNTG5DeS03YmtFTjg3NWRaMTRrbHQ1cmJGb3lWc1otdG5QWGlQY05rUmtKb0RwWkg0a2ljSHRTS2haZlZJMmxtSnljOG1IMTNxOHg; session_tracker=thFScnLWPDid0dKyY1.0.1579474128023.Z0FBQUFBQmVKTnpRdzlkZGpscy1NbVRtRmpBQThvS3NZeXlNeTZYMEdrYjBPeDFlMlJGVHlaZGxTTGNYSC1RVnRla2t1WGJ0aVJ5Z0Rmdks1UHFTc3ROa2tWQ3BmeXVMSUZtMVVRSEdDdXZlQTVDcnNaZmJ1UGdSeWQ3d1RfdmpuU1NvWmtGcFhyRVI" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "4536" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:48 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21951-LGA" + ], + "X-Timer": [ + "S1579474128.106597,VS0,VE194" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=thFScnLWPDid0dKyY1.0.1579474128235.Z0FBQUFBQmVKTnpRdU1vMU5LX0NCR01mQy1QVV9nV1BGRXFMV3ZUdW9uMnVBSV94dHZ1WlBKNUNja2Jta0lCMUZCWXVlZ29BRXBSN0pya0tFM3hPLXJ4VVRGYkQzM0t6aDRtNlotUEhCRmZQY3NsTEFhYmRBR0FTbUVpTEdKNHlSajZRa1VDd0ZEdVY; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:48 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "592.0" + ], + "x-ratelimit-reset": [ + "72" + ], + "x-ratelimit-used": [ + "8" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + } + }, + { + "recorded_at": "2020-01-19T22:48:48", + "request": { + "body": { + "encoding": "utf-8", + "string": "allowable_content=all&api_type=json&background_color=%2300FFFF&css_class=myCSS&flair_template_id=488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf&max_emojis=10&mod_only=False&text=PRAW+updated&text_color=dark&text_editable=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "216" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=jLGeRnO8HD6Z9f0tsr; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpRQXlwSTF6VDhZMzJlZkF2NDNuVkFwWTk5Q0MzMUkzeFZmdUZZamdHX0JUeHIwd29iSTdEaXNNTG5DeS03YmtFTjg3NWRaMTRrbHQ1cmJGb3lWc1otdG5QWGlQY05rUmtKb0RwWkg0a2ljSHRTS2haZlZJMmxtSnljOG1IMTNxOHg; session_tracker=thFScnLWPDid0dKyY1.0.1579474128235.Z0FBQUFBQmVKTnpRdU1vMU5LX0NCR01mQy1QVV9nV1BGRXFMV3ZUdW9uMnVBSV94dHZ1WlBKNUNja2Jta0lCMUZCWXVlZ29BRXBSN0pya0tFM3hPLXJ4VVRGYkQzM0t6aDRtNlotUEhCRmZQY3NsTEFhYmRBR0FTbUVpTEdKNHlSajZRa1VDd0ZEdVY" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"text\": \"PRAW updated\", \"allowableContent\": \"all\", \"modOnly\": false, \"cssClass\": \"myCSS\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"textEditable\": false, \"overrideCss\": false, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"maxEmojis\": 10, \"flairType\": \"USER_FLAIR\", \"backgroundColor\": \"#00ffff\", \"textColor\": \"dark\", \"type\": \"richtext\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "346" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:48 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21951-LGA" + ], + "X-Timer": [ + "S1579474128.418299,VS0,VE160" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=thFScnLWPDid0dKyY1.0.1579474128475.Z0FBQUFBQmVKTnpRajI0WGNEY0NJVFdERC12X2FhX3ZpUnIwREdHT1hwejFMZFpwcTJyQjZITlN3QjJTVGphSHpiZmRvUXBZdnNlSzZGelRPblg2bFJNdW1Peml4dXBscmN4d3lwQk4zcHVPeC1fQXhXeDBrSEtnQ2hKOFl5OW9xVmNyNXNFOTI1bm0; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:48 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "591.0" + ], + "x-ratelimit-reset": [ + "72" + ], + "x-ratelimit-used": [ + "9" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_no_text_or_css_class.json b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_no_text_or_css_class.json new file mode 100644 index 00000000..6f34e5ac --- /dev/null +++ b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_no_text_or_css_class.json @@ -0,0 +1,458 @@ +{ + "http_interactions": [ + { + "recorded_at": "2020-01-19T22:48:48", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=<PASSWORD>&username=<USERNAME>" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic <BASIC_AUTH>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "61" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:48 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=i8AbBGGo50gXg33d1g; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21938-LGA" + ], + "X-Timer": [ + "S1579474129.694844,VS0,VE302" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2020-01-19T22:48:49", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=i8AbBGGo50gXg33d1g" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "4536" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:49 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21980-LGA" + ], + "X-Timer": [ + "S1579474129.098486,VS0,VE126" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpSdk1CYmtuZEVVY3YzOEJidktIN3lfc0ljQkZCTUlac1ZyNnVKRTVKR0FfU2FIVFJYSWYxbUFJRXlPaEJkOVZhRU1yRVREaldGQjVCWXlnM3NmaWdwTVJkVno5RTZuWW80c18zQldad2FxRVJBb1pSdUNMM011Z2VKal9UcGs4azU; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 18-Jan-2022 22:48:49 GMT; secure", + "session_tracker=CSd2b1VNSbQsRmOqZb.0.1579474129132.Z0FBQUFBQmVKTnpSLVRvb0Z5UTdBX21HYzFud3hyTjZoZU16SFNRV1VNZHY4NWF6UjdpYlc4M2JqTTFyZGV6RzBnSjFZZ2FfaTRNRkRGa2ZpcE41X1QtM2F5TWpGUEZfNkpNWVJpN19QSVRkTjAwTkVETF9xR2VZRDdOUV9DRlpxOHliemFnQ01PNGo; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:49 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "590.0" + ], + "x-ratelimit-reset": [ + "71" + ], + "x-ratelimit-used": [ + "10" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + } + }, + { + "recorded_at": "2020-01-19T22:48:49", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=i8AbBGGo50gXg33d1g; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpSdk1CYmtuZEVVY3YzOEJidktIN3lfc0ljQkZCTUlac1ZyNnVKRTVKR0FfU2FIVFJYSWYxbUFJRXlPaEJkOVZhRU1yRVREaldGQjVCWXlnM3NmaWdwTVJkVno5RTZuWW80c18zQldad2FxRVJBb1pSdUNMM011Z2VKal9UcGs4azU; session_tracker=CSd2b1VNSbQsRmOqZb.0.1579474129132.Z0FBQUFBQmVKTnpSLVRvb0Z5UTdBX21HYzFud3hyTjZoZU16SFNRV1VNZHY4NWF6UjdpYlc4M2JqTTFyZGV6RzBnSjFZZ2FfaTRNRkRGa2ZpcE41X1QtM2F5TWpGUEZfNkpNWVJpN19QSVRkTjAwTkVETF9xR2VZRDdOUV9DRlpxOHliemFnQ01PNGo" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "4536" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:49 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21980-LGA" + ], + "X-Timer": [ + "S1579474129.251324,VS0,VE150" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=CSd2b1VNSbQsRmOqZb.0.1579474129281.Z0FBQUFBQmVKTnpSelJkaHRIek8tblBqZ1Q2UFVkazZSc1VJVUhSb0ZkVXQxSWZUdmhDV0paRmlkM0F3aTc2QWxrLWluQV81WXVpb2ZQUWhIU0EtdG1TdjRZaXlaX1A3Uk01cHY0bW9JTWRZcF9nenFXMjkwcHh6VUU4bmMtQndlclVSTVBvNzN2c0o; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:49 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "589.0" + ], + "x-ratelimit-reset": [ + "71" + ], + "x-ratelimit-used": [ + "11" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + } + }, + { + "recorded_at": "2020-01-19T22:48:49", + "request": { + "body": { + "encoding": "utf-8", + "string": "allowable_content=all&api_type=json&background_color=%2300FFFF&css_class=myCSS&flair_template_id=488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf&max_emojis=10&mod_only=False&text=PRAW+updated&text_color=dark&text_editable=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "216" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=i8AbBGGo50gXg33d1g; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTnpSdk1CYmtuZEVVY3YzOEJidktIN3lfc0ljQkZCTUlac1ZyNnVKRTVKR0FfU2FIVFJYSWYxbUFJRXlPaEJkOVZhRU1yRVREaldGQjVCWXlnM3NmaWdwTVJkVno5RTZuWW80c18zQldad2FxRVJBb1pSdUNMM011Z2VKal9UcGs4azU; session_tracker=CSd2b1VNSbQsRmOqZb.0.1579474129281.Z0FBQUFBQmVKTnpSelJkaHRIek8tblBqZ1Q2UFVkazZSc1VJVUhSb0ZkVXQxSWZUdmhDV0paRmlkM0F3aTc2QWxrLWluQV81WXVpb2ZQUWhIU0EtdG1TdjRZaXlaX1A3Uk01cHY0bW9JTWRZcF9nenFXMjkwcHh6VUU4bmMtQndlclVSTVBvNzN2c0o" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"text\": \"PRAW updated\", \"allowableContent\": \"all\", \"modOnly\": false, \"cssClass\": \"myCSS\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"textEditable\": false, \"overrideCss\": false, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"maxEmojis\": 10, \"flairType\": \"USER_FLAIR\", \"backgroundColor\": \"#00ffff\", \"textColor\": \"dark\", \"type\": \"richtext\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "346" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:48:49 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21980-LGA" + ], + "X-Timer": [ + "S1579474129.427613,VS0,VE139" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=CSd2b1VNSbQsRmOqZb.0.1579474129458.Z0FBQUFBQmVKTnpSS1kzWmVQaVF2LUV6c2ltdFZPa2FQamF4SGlqWEIxZ2EtTmo2T1drV2J0RUFtTzUtUzhiYVR5UWl3THpfRmFndHRYX3BUczNWSjJBYUM5VnQtMld0N05hT29DaUJVUXdVeENHYWlPajY4Q1d1SDQ0Z1pmZDljN21zdFdDZzZKR0k; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:48:49 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "588.0" + ], + "x-ratelimit-reset": [ + "71" + ], + "x-ratelimit-used": [ + "12" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_only.json b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_only.json new file mode 100644 index 00000000..d2814001 --- /dev/null +++ b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_fetch_only.json @@ -0,0 +1,574 @@ +{ + "http_interactions": [ + { + "recorded_at": "2020-01-19T22:49:47", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=<PASSWORD>&username=<USERNAME>" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic <BASIC_AUTH>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "61" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:49:47 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=Vk47IkUCViKwhmkXUR; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21932-LGA" + ], + "X-Timer": [ + "S1579474187.118549,VS0,VE321" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2020-01-19T22:49:47", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=Vk47IkUCViKwhmkXUR" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"fdd612e4-3b0d-11ea-9392-0e87026a9dfd\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "4865" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:49:47 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21945-LGA" + ], + "X-Timer": [ + "S1579474188.579549,VS0,VE81" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTjBMVUN0ZHUwYjJMQjVCaGhWbU1OUVBvRTVDMnB1SDhQc3NFTFNGQWg4YVNPRzVKUGFHSV9kU3htY3VFdGVTZXgtUjh6SDBueGRyWHIxTWlwN1JPUmUyZ1ZTVFhNN1lNMkg1QnpaVWkxX1pDalZVVFlYRWlQQ3E3Q2psczdNc2NDOXk; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 18-Jan-2022 22:49:47 GMT; secure", + "session_tracker=rQy76gkbDNYcwdSyU6.0.1579474187611.Z0FBQUFBQmVKTjBMemFteGxGOURRQ0pmQjNQemgwM3QzckdhVlIyaGRrWWtUX0dxT0oyZndiaWM2UnJwU2tZOXRkVmdSM2R6emd2UXRJSjRkcWVoekZrS1hBcDRGU3A2LVpBd3JDTy1rcmNibjluQklmNzVFdm1XRmVYX1V0RDBwYU5YRDdXX2pzRHA; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:49:47 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "586.0" + ], + "x-ratelimit-reset": [ + "13" + ], + "x-ratelimit-used": [ + "14" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + } + }, + { + "recorded_at": "2020-01-19T22:49:47", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=Vk47IkUCViKwhmkXUR; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTjBMVUN0ZHUwYjJMQjVCaGhWbU1OUVBvRTVDMnB1SDhQc3NFTFNGQWg4YVNPRzVKUGFHSV9kU3htY3VFdGVTZXgtUjh6SDBueGRyWHIxTWlwN1JPUmUyZ1ZTVFhNN1lNMkg1QnpaVWkxX1pDalZVVFlYRWlQQ3E3Q2psczdNc2NDOXk; session_tracker=rQy76gkbDNYcwdSyU6.0.1579474187611.Z0FBQUFBQmVKTjBMemFteGxGOURRQ0pmQjNQemgwM3QzckdhVlIyaGRrWWtUX0dxT0oyZndiaWM2UnJwU2tZOXRkVmdSM2R6emd2UXRJSjRkcWVoekZrS1hBcDRGU3A2LVpBd3JDTy1rcmNibjluQklmNzVFdm1XRmVYX1V0RDBwYU5YRDdXX2pzRHA" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"fdd612e4-3b0d-11ea-9392-0e87026a9dfd\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "4865" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:49:47 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21945-LGA" + ], + "X-Timer": [ + "S1579474188.684757,VS0,VE118" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=rQy76gkbDNYcwdSyU6.0.1579474187729.Z0FBQUFBQmVKTjBMWEhNMWI1SkRiaENZSGdBS0N0S0NCUjdfN2I1RWlSSkk3Vy1JejNkcmcyV2dkTDhPWDFpQ2NyYUlmMWtyOWNIRkFQSmlfUy05Z3g3cU9YUEhlbHl2YXYxd1UtREFnby1zbEFEdERzdDdPaHIwa0x1R3RQN2hpdXBhWVRkNHdtcTM; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:49:47 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "585.0" + ], + "x-ratelimit-reset": [ + "13" + ], + "x-ratelimit-used": [ + "15" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=1&raw_json=1" + } + }, + { + "recorded_at": "2020-01-19T22:49:48", + "request": { + "body": { + "encoding": "utf-8", + "string": "allowable_content=all&api_type=json&background_color=%2300ffff&css_class=myCSS&flair_template_id=488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf&max_emojis=10&mod_only=False&text=PRAW+updated&text_color=dark&text_editable=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "216" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=Vk47IkUCViKwhmkXUR; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTjBMVUN0ZHUwYjJMQjVCaGhWbU1OUVBvRTVDMnB1SDhQc3NFTFNGQWg4YVNPRzVKUGFHSV9kU3htY3VFdGVTZXgtUjh6SDBueGRyWHIxTWlwN1JPUmUyZ1ZTVFhNN1lNMkg1QnpaVWkxX1pDalZVVFlYRWlQQ3E3Q2psczdNc2NDOXk; session_tracker=rQy76gkbDNYcwdSyU6.0.1579474187729.Z0FBQUFBQmVKTjBMWEhNMWI1SkRiaENZSGdBS0N0S0NCUjdfN2I1RWlSSkk3Vy1JejNkcmcyV2dkTDhPWDFpQ2NyYUlmMWtyOWNIRkFQSmlfUy05Z3g3cU9YUEhlbHl2YXYxd1UtREFnby1zbEFEdERzdDdPaHIwa0x1R3RQN2hpdXBhWVRkNHdtcTM" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"text\": \"PRAW updated\", \"allowableContent\": \"all\", \"modOnly\": false, \"cssClass\": \"myCSS\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"textEditable\": false, \"overrideCss\": false, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"maxEmojis\": 10, \"flairType\": \"USER_FLAIR\", \"backgroundColor\": \"#00ffff\", \"textColor\": \"dark\", \"type\": \"richtext\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "346" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:49:48 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21945-LGA" + ], + "X-Timer": [ + "S1579474188.829481,VS0,VE180" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=rQy76gkbDNYcwdSyU6.0.1579474187879.Z0FBQUFBQmVKTjBNTE5CZWxsdTJaZ1owdHlWSTBBOUpHT0tYMnY2TkF0UFgzZUZ1Y3FEOFZoTnBGRUZFenlQOERSX1duYU1kOHBmblQ5S2VWT2JJNzlXSEYyQl9fRnBheVplOUczdTBFeXhmLU9QQ0ZCU2dTQWJBMmNKeEJZY3FXcmREWUZscGxaNnU; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:49:48 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "584.0" + ], + "x-ratelimit-reset": [ + "13" + ], + "x-ratelimit-used": [ + "16" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/flairtemplate_v2?raw_json=1" + } + }, + { + "recorded_at": "2020-01-19T22:49:48", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=Vk47IkUCViKwhmkXUR; loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKTjBMVUN0ZHUwYjJMQjVCaGhWbU1OUVBvRTVDMnB1SDhQc3NFTFNGQWg4YVNPRzVKUGFHSV9kU3htY3VFdGVTZXgtUjh6SDBueGRyWHIxTWlwN1JPUmUyZ1ZTVFhNN1lNMkg1QnpaVWkxX1pDalZVVFlYRWlQQ3E3Q2psczdNc2NDOXk; session_tracker=rQy76gkbDNYcwdSyU6.0.1579474187879.Z0FBQUFBQmVKTjBNTE5CZWxsdTJaZ1owdHlWSTBBOUpHT0tYMnY2TkF0UFgzZUZ1Y3FEOFZoTnBGRUZFenlQOERSX1duYU1kOHBmblQ5S2VWT2JJNzlXSEYyQl9fRnBheVplOUczdTBFeXhmLU9QQ0ZCU2dTQWJBMmNKeEJZY3FXcmREWUZscGxaNnU" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=2&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"fdd612e4-3b0d-11ea-9392-0e87026a9dfd\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "4865" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 22:49:48 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21945-LGA" + ], + "X-Timer": [ + "S1579474188.034768,VS0,VE113" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=rQy76gkbDNYcwdSyU6.0.1579474188064.Z0FBQUFBQmVKTjBNaUhIX21rUFBrZmpWM3FVZmIzaW9kcnZiX19BbWhDYTZCRGtSSmpsclZaamVzVFVhZk5MMGdkM2dyWFRyWDhkNUk5ZUw2dGwyZVNESUlGcXFzTTB5eGVYbDhXZDd1WHRxcVBURmdBWGM2V0RTdy1qYWRYNGdWYjdpUnhfSDEyMWI; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 00:49:48 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "583.0" + ], + "x-ratelimit-reset": [ + "12" + ], + "x-ratelimit-used": [ + "17" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=2&raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_invalid.json b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_invalid.json new file mode 100644 index 00000000..14fe8044 --- /dev/null +++ b/tests/integration/cassettes/TestSubredditFlairTemplates.test_update_invalid.json @@ -0,0 +1,223 @@ +{ + "http_interactions": [ + { + "recorded_at": "2020-01-19T23:13:59", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=<PASSWORD>&username=<USERNAME>" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic <BASIC_AUTH>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "61" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 23:13:58 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=pGdNCrVvuF2QbB0Na4; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21969-LGA" + ], + "X-Timer": [ + "S1579475639.591107,VS0,VE374" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2020-01-19T23:13:59", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=pGdNCrVvuF2QbB0Na4" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/6.6.0.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "[{\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"488f9b30-2a6e-11ea-a5e1-0e48d7ccc6bf\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"Test\", \"text_color\": \"light\", \"mod_only\": false, \"background_color\": \"#cc8b00\", \"id\": \"0be1ace4-2a75-11ea-8018-0ecef10bc461\", \"css_class\": \"sdgdsgdfg\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"Test\"}], \"text_editable\": true, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"c35e4e9e-2c01-11ea-8f5b-0e0a652f3127\", \"css_class\": \"safd\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"sd\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"c6770634-2c0b-11ea-b2c4-0eb2086522d7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"sd\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_2343432423434234\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9f4aed66-2c31-11ea-83ce-0e82e83845bb\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_2343432423434234\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"19c3c7e8-2c32-11ea-8f52-0e9efc12a42d\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"0c697326-2c33-11ea-a8a2-0e2c4841c615\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"411e3a8e-2c33-11ea-8867-0ecb0295a08f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"test_-6272344502281197854\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"1caba762-2c34-11ea-9ce7-0ee91a3979a3\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-6272344502281197854\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_-5907897697623735472\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"4f5c14ee-2c34-11ea-9619-0e0e030ac6b1\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_-5907897697623735472\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_4334785974679089788\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"9522e976-2c34-11ea-8cbe-0ed81bd53a3f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_4334785974679089788\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"0c5566e0-2c35-11ea-b4fa-0e34689a2fff\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"uihrreiuhgreuihgreiuhgeriugreigeriuhg\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test_7400363879098893801\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"38141cd6-2c3a-11ea-bcfd-0ead7f7cca81\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test_7400363879098893801\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"test124\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"transparent\", \"id\": \"f93339d8-2ce4-11ea-9877-0ece4d97dd21\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"test124\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"PRAW updated\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"#00ffff\", \"id\": \"fdd612e4-3b0d-11ea-9392-0e87026a9dfd\", \"css_class\": \"myCSS\", \"max_emojis\": 10, \"richtext\": [{\"e\": \"text\", \"t\": \"PRAW updated\"}], \"text_editable\": false, \"override_css\": false, \"type\": \"richtext\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"8d42a7ec-3b10-11ea-aa60-0ec419547aa7\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"9888b31c-3b10-11ea-ba79-0e8eeb7625d9\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"d564a2b4-3b10-11ea-9c27-0e38b4413acd\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"11b600fa-3b11-11ea-9965-0ede2116dd5f\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}, {\"allowable_content\": \"all\", \"text\": \"\", \"text_color\": \"dark\", \"mod_only\": false, \"background_color\": \"\", \"id\": \"2654bdee-3b11-11ea-be6e-0e368dee9941\", \"css_class\": \"\", \"max_emojis\": 10, \"richtext\": [], \"text_editable\": false, \"override_css\": false, \"type\": \"text\"}]" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "6200" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 19 Jan 2020 23:13:59 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21940-LGA" + ], + "X-Timer": [ + "S1579475639.232454,VS0,VE184" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=00000000005bn5wlvy.2.1577584524387.Z0FBQUFBQmVKT0szbUQzYkFVdmdFdlNOSE5sQTl6UGVibmNJQzRfYTRWRzNMTHBVZ3pYbjJoVGZTdDhzQU1MS0J1dDlrbm0yeU9sQWFCY291SkpMQnFwUWltS1drTGw0eW9HS1RMcDJOUDRXMkdKM1M2WVdpX0VDR1VnWXctU3B0Z240ZWFGWXJSYk0; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 18-Jan-2022 23:13:59 GMT; secure", + "session_tracker=QAFOWOMGjQyCXk8Wfo.0.1579475639351.Z0FBQUFBQmVKT0szWXZTd3BYMDFzaTA1UTN6cDlFX2UxeHlpWVMzZVlsUTNKY3o3b2pSaTh3Sm9FbGluNVY1NDJ1X09Qdm5YZUM5aGNzdzBFcC1Cd3dOZ0owekZ5UDdQS1RUbUxxR3BlbDFqbl90Yk1RR29KQmdsc3dkdUhQUFBNZDNCRGdDWHNQUmg; Domain=reddit.com; Max-Age=7199; Path=/; expires=Mon, 20-Jan-2020 01:13:59 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "599.0" + ], + "x-ratelimit-reset": [ + "361" + ], + "x-ratelimit-used": [ + "1" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r/<TEST_SUBREDDIT>/api/user_flair_v2?unique=0&raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/models/reddit/test_subreddit.py b/tests/integration/models/reddit/test_subreddit.py index 8f5bfae9..dc864c25 100644 --- a/tests/integration/models/reddit/test_subreddit.py +++ b/tests/integration/models/reddit/test_subreddit.py @@ -4,7 +4,12 @@ from json import dumps import socket import sys -from praw.exceptions import APIException, ClientException, WebSocketException +from praw.exceptions import ( + APIException, + ClientException, + InvalidFlairTemplateID, + WebSocketException, +) from praw.models import ( Comment, ModAction, @@ -79,11 +84,6 @@ class WebsocketMockException: ) -def raise_exception(exception): - """Raise the specified exception.""" - raise exception - - class TestSubreddit(IntegrationTest): @staticmethod def image_path(name): @@ -1009,6 +1009,122 @@ class TestSubredditFlairTemplates(IntegrationTest): background_color="#00FFFF", ) + @mock.patch("time.sleep", return_value=None) + def test_update_invalid(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestSubredditFlairTemplates.test_update_invalid" + ): + with pytest.raises(InvalidFlairTemplateID): + self.subreddit.flair.templates.update( + "fake id", + "PRAW updated", + css_class="myCSS", + text_color="dark", + background_color="#00FFFF", + fetch=True, + ) + + @mock.patch("time.sleep", return_value=None) + def test_update_fetch(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestSubredditFlairTemplates.test_update_fetch" + ): + template = list(self.subreddit.flair.templates)[0] + self.subreddit.flair.templates.update( + template["id"], + "PRAW updated", + css_class="myCSS", + text_color="dark", + background_color="#00FFFF", + fetch=True, + ) + + @mock.patch("time.sleep", return_value=None) + def test_update_fetch_no_css_class(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestSubredditFlairTemplates.test_update_fetch_no_css_class" + ): + template = list(self.subreddit.flair.templates)[0] + self.subreddit.flair.templates.update( + template["id"], + "PRAW updated", + text_color="dark", + background_color="#00FFFF", + fetch=True, + ) + + @mock.patch("time.sleep", return_value=None) + def test_update_fetch_no_text(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestSubredditFlairTemplates.test_update_fetch_no_text" + ): + template = list(self.subreddit.flair.templates)[0] + self.subreddit.flair.templates.update( + template["id"], + css_class="myCSS", + text_color="dark", + background_color="#00FFFF", + fetch=True, + ) + + @mock.patch("time.sleep", return_value=None) + def test_update_fetch_no_text_or_css_class(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestSubredditFlairTemplates.test_update_fetch_" + "no_text_or_css_class" + ): + template = list(self.subreddit.flair.templates)[0] + self.subreddit.flair.templates.update( + template["id"], + text_color="dark", + background_color="#00FFFF", + fetch=True, + ) + + @mock.patch("time.sleep", return_value=None) + def test_update_fetch_only(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestSubredditFlairTemplates.test_update_fetch_only" + ): + template = list(self.subreddit.flair.templates)[0] + self.subreddit.flair.templates.update( + template["id"], fetch=True, + ) + newtemplate = list( + filter( + lambda _template: _template["id"] == template["id"], + self.subreddit.flair.templates, + ) + )[0] + assert newtemplate == template + + @mock.patch("time.sleep", return_value=None) + def test_update_false(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestSubredditFlairTemplates.test_update_false" + ): + template = list(self.subreddit.flair.templates)[0] + self.subreddit.flair.templates.update( + template["id"], text_editable=True, fetch=True, + ) + self.subreddit.flair.templates.update( + template["id"], text_editable=False, fetch=True, + ) + newtemplate = list( + filter( + lambda _template: _template["id"] == template["id"], + self.subreddit.flair.templates, + ) + )[0] + assert newtemplate["text_editable"] is False + class TestSubredditLinkFlairTemplates(IntegrationTest): @property diff --git a/tests/unit/models/reddit/test_subreddit.py b/tests/unit/models/reddit/test_subreddit.py index b37e9153..111d5b97 100644 --- a/tests/unit/models/reddit/test_subreddit.py +++ b/tests/unit/models/reddit/test_subreddit.py @@ -2,6 +2,7 @@ import pickle import pytest from praw.models import Subreddit, WikiPage +from praw.models.reddit.subreddit import SubredditFlairTemplates from ... import UnitTest @@ -117,6 +118,14 @@ class TestSubredditFlair(UnitTest): ) +class TestSubredditFlairTemplates(UnitTest): + def test_not_implemented(self): + with pytest.raises(NotImplementedError): + SubredditFlairTemplates( + Subreddit(self.reddit, pytest.placeholders.test_subreddit) + ).__iter__() + + class TestSubredditWiki(UnitTest): def test__getitem(self): subreddit = Subreddit(self.reddit, display_name="name") diff --git a/tests/unit/test_exceptions.py b/tests/unit/test_exceptions.py index b9a35128..b6668372 100644 --- a/tests/unit/test_exceptions.py +++ b/tests/unit/test_exceptions.py @@ -3,6 +3,7 @@ from praw.exceptions import ( APIException, ClientException, DuplicateReplaceException, + InvalidFlairTemplateID, InvalidURL, InvalidImplicitAuth, MissingRequiredAttributeException, @@ -54,6 +55,18 @@ class TestDuplicateReplaceException: ) +class TestInvalidFlairTemplateID: + def test_inheritance(self): + assert isinstance(InvalidFlairTemplateID(None), ClientException) + + def test_str(self): + assert ( + str(InvalidFlairTemplateID("123")) + == "The flair template id ``123`` is invalid. If you are " + "trying to create a flair, please use the ``add`` method." + ) + + class TestInvalidImplicitAuth: def test_inheritance(self): assert isinstance(InvalidImplicitAuth(), ClientException)
SubredditFlairTemplates.update nullifies/overwrites existing values if not given ## Issue Description The current [SubredditFlairTemplates.update](https://github.com/praw-dev/praw/blob/master/praw/models/reddit/subreddit.py#L1236) method nullifies/overwrites existing values if not given as inputs to the method, instead of retaining them and only modifying the inputs given. Although this is documented, it would be preferable to only update the values given as inputs to the call.
0.0
428ca8ff0ad1ef0f5ab58ef423dac16fb0e2b9c3
[ "tests/unit/test_exceptions.py::TestPRAWException::test_inheritance", "tests/unit/test_exceptions.py::TestPRAWException::test_str", "tests/unit/test_exceptions.py::TestAPIException::test_inheritance", "tests/unit/test_exceptions.py::TestAPIException::test_str", "tests/unit/test_exceptions.py::TestClientException::test_inheritance", "tests/unit/test_exceptions.py::TestClientException::test_str", "tests/unit/test_exceptions.py::TestDuplicateReplaceException::test_inheritance", "tests/unit/test_exceptions.py::TestDuplicateReplaceException::test_message", "tests/unit/test_exceptions.py::TestInvalidFlairTemplateID::test_inheritance", "tests/unit/test_exceptions.py::TestInvalidFlairTemplateID::test_str", "tests/unit/test_exceptions.py::TestInvalidImplicitAuth::test_inheritance", "tests/unit/test_exceptions.py::TestInvalidImplicitAuth::test_message", "tests/unit/test_exceptions.py::TestInvalidURL::test_inheritance", "tests/unit/test_exceptions.py::TestInvalidURL::test_message", "tests/unit/test_exceptions.py::TestInvalidURL::test_custom_message", "tests/unit/test_exceptions.py::TestMissingRequiredAttributeException::test_inheritance", "tests/unit/test_exceptions.py::TestMissingRequiredAttributeException::test_str", "tests/unit/test_exceptions.py::TestWebSocketException::test_inheritance", "tests/unit/test_exceptions.py::TestWebSocketException::test_str", "tests/unit/test_exceptions.py::TestWebSocketException::test_exception_attr" ]
[]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2020-01-18 03:31:52+00:00
bsd-2-clause
4,647
praw-dev__praw-1960
diff --git a/CHANGES.rst b/CHANGES.rst index 2d776d7d..b893f83f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,10 @@ PRAW follows `semantic versioning <http://semver.org/>`_. Unreleased ---------- +**Fixed** + +- An issue with replying to a modmail conversation results in a error. + 7.7.0 (2023/02/25) ------------------ diff --git a/praw/models/reddit/modmail.py b/praw/models/reddit/modmail.py index 2bdb981c..3ee6f08d 100644 --- a/praw/models/reddit/modmail.py +++ b/praw/models/reddit/modmail.py @@ -257,9 +257,15 @@ class ModmailConversation(RedditBase): response = self._reddit.post( API_PATH["modmail_conversation"].format(id=self.id), data=data ) - message_id = response["conversation"]["objIds"][-1]["id"] - message_data = response["messages"][message_id] - return self._reddit._objector.objectify(message_data) + if isinstance(response, dict): + # Reddit recently changed the response format, so we need to handle both in case they change it back + message_id = response["conversation"]["objIds"][-1]["id"] + message_data = response["messages"][message_id] + return self._reddit._objector.objectify(message_data) + else: + for message in response.messages: + if message.id == response.obj_ids[-1]["id"]: + return message def unarchive(self): """Unarchive the conversation.
praw-dev/praw
8bf669309a1476fa995f99c87c895fadf5436563
diff --git a/tests/integration/cassettes/TestModmailConversation.test_reply__internal.json b/tests/integration/cassettes/TestModmailConversation.test_reply__internal.json new file mode 100644 index 00000000..5d10d7e1 --- /dev/null +++ b/tests/integration/cassettes/TestModmailConversation.test_reply__internal.json @@ -0,0 +1,217 @@ +{ + "http_interactions": [ + { + "recorded_at": "2023-07-11T20:33:14", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=refresh_token&refresh_token=<REFRESH_TOKEN>" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic <BASIC_AUTH>" + ], + "Connection": [ + "close" + ], + "Content-Length": [ + "82" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/7.7.1.dev0 prawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 86400, \"refresh_token\": \"<REFRESH_TOKEN>\", \"scope\": \"creddits modnote modcontributors modmail modconfig subscribe structuredstyles vote wikiedit mysubreddits submit modlog modposts modflair save modothers read privatemessages report identity livemanage account modtraffic wikiread edit modwiki modself history flair\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, max-age=3600" + ], + "Connection": [ + "close" + ], + "Content-Length": [ + "1527" + ], + "Date": [ + "Tue, 11 Jul 2023 20:33:14 GMT" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 1.0, \"failure_fraction\": 1.0}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}, {\"group\": \"w3-reporting-csp\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-csp.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=lUgiOW4d9OwlvT1wgL; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "content-type": [ + "application/json; charset=UTF-8" + ], + "x-moose": [ + "majestic" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2023-07-11T20:33:14", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&body=A+message&isAuthorHidden=False&isInternal=True" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer <ACCESS_TOKEN>" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "65" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=lUgiOW4d9OwlvT1wgL" + ], + "User-Agent": [ + "<USER_AGENT> PRAW/7.7.1.dev0 prawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/mod/conversations/1mahha?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"conversation\": {\"isAuto\": false, \"participant\": {\"isMod\": true, \"isAdmin\": false, \"name\": \"<USERNAME>\", \"isOp\": true, \"isParticipant\": true, \"isApproved\": false, \"isHidden\": false, \"id\": 561251419067, \"isDeleted\": false}, \"objIds\": [{\"id\": \"2bjn0i\", \"key\": \"messages\"}, {\"id\": \"2bjn0k\", \"key\": \"messages\"}, {\"id\": \"2bjn2z\", \"key\": \"messages\"}], \"isRepliable\": true, \"lastUserUpdate\": null, \"isInternal\": false, \"lastModUpdate\": \"2023-07-11T20:33:14.617000+0000\", \"authors\": [{\"isMod\": true, \"isAdmin\": false, \"name\": \"<USERNAME>\", \"isOp\": true, \"isParticipant\": true, \"isApproved\": false, \"isHidden\": false, \"id\": 561251419067, \"isDeleted\": false}], \"lastUpdated\": \"2023-07-11T20:33:14.617000+0000\", \"participantSubreddit\": {}, \"legacyFirstMessageId\": \"1wttevy\", \"state\": 1, \"conversationType\": \"sr_user\", \"lastUnread\": \"2023-07-11T00:00:00.000000+0000\", \"owner\": {\"displayName\": \"<TEST_SUBREDDIT>\", \"type\": \"subreddit\", \"id\": \"t5_29ey0j\"}, \"subject\": \"test\", \"id\": \"1mahha\", \"isHighlighted\": false, \"numMessages\": 3}, \"participantSubreddit\": {}, \"messages\": {\"2bjn0k\": {\"body\": \"<!-- SC_OFF --><div class=\\\"md\\\"><p>additional test</p>\\n</div><!-- SC_ON -->\", \"author\": {\"name\": \"<USERNAME>\", \"isApproved\": false, \"isMod\": true, \"isAdmin\": false, \"isOp\": true, \"isParticipant\": true, \"isHidden\": false, \"id\": 561251419067, \"isDeleted\": false}, \"isInternal\": true, \"date\": \"2023-07-11T20:32:12.025000+0000\", \"bodyMarkdown\": \"additional test\", \"id\": \"2bjn0k\", \"participatingAs\": \"moderator\"}, \"2bjn0i\": {\"body\": \"<!-- SC_OFF --><div class=\\\"md\\\"><p>testing</p>\\n</div><!-- SC_ON -->\", \"author\": {\"name\": \"<USERNAME>\", \"isApproved\": false, \"isMod\": true, \"isAdmin\": false, \"isOp\": true, \"isParticipant\": true, \"isHidden\": true, \"id\": 561251419067, \"isDeleted\": false}, \"isInternal\": false, \"date\": \"2023-07-11T20:32:11.586000+0000\", \"bodyMarkdown\": \"testing\", \"id\": \"2bjn0i\", \"participatingAs\": \"moderator\"}, \"2bjn2z\": {\"body\": \"<!-- SC_OFF --><div class=\\\"md\\\"><p>A message</p>\\n</div><!-- SC_ON -->\", \"author\": {\"name\": \"<USERNAME>\", \"isApproved\": false, \"isMod\": true, \"isAdmin\": false, \"isOp\": true, \"isParticipant\": true, \"isHidden\": false, \"id\": 561251419067, \"isDeleted\": false}, \"isInternal\": true, \"date\": \"2023-07-11T20:33:14.617000+0000\", \"bodyMarkdown\": \"A message\", \"id\": \"2bjn2z\", \"participatingAs\": \"moderator\"}}, \"user\": {\"recentComments\": {\"t1_i6yklz7\": {\"comment\": \"test reply\", \"date\": \"2022-05-01T22:37:21.936000+00:00\", \"permalink\": \"https://www.reddit.com/r/<TEST_SUBREDDIT>/comments/uflrmv/test_post/i6yklz7/\", \"title\": \"Test post\"}}, \"muteStatus\": {\"muteCount\": 0, \"isMuted\": false, \"endDate\": null, \"reason\": \"\"}, \"name\": \"<USERNAME>\", \"created\": \"2020-07-04T21:34:49.063000+00:00\", \"banStatus\": {\"endDate\": null, \"reason\": \"\", \"isBanned\": false, \"isPermanent\": false}, \"isSuspended\": false, \"approveStatus\": {\"isApproved\": false}, \"isShadowBanned\": false, \"recentPosts\": {\"t3_z3wwe8\": {\"date\": \"2022-11-24T22:47:02.992000+00:00\", \"permalink\": \"https://www.reddit.com/r/<TEST_SUBREDDIT>/comments/z3wwe8/test_post/\", \"title\": \"Test post\"}, \"t3_z4lkt4\": {\"date\": \"2022-11-25T19:16:07.058000+00:00\", \"permalink\": \"https://www.reddit.com/r/<TEST_SUBREDDIT>/comments/z4lkt4/test_post/\", \"title\": \"Test post\"}, \"t3_z3x0le\": {\"date\": \"2022-11-24T22:52:25.348000+00:00\", \"permalink\": \"https://www.reddit.com/r/<TEST_SUBREDDIT>/comments/z3x0le/test_post/\", \"title\": \"Test post\"}, \"t3_z3xa9p\": {\"date\": \"2022-11-24T23:04:17.179000+00:00\", \"permalink\": \"https://www.reddit.com/r/<TEST_SUBREDDIT>/comments/z3xa9p/test_post/\", \"title\": \"Test post\"}, \"t3_z3wslj\": {\"date\": \"2022-11-24T22:42:19.611000+00:00\", \"permalink\": \"https://www.reddit.com/r/<TEST_SUBREDDIT>/comments/z3wslj/test_post/\", \"title\": \"Test post\"}, \"t3_z3wtr9\": {\"date\": \"2022-11-24T22:43:43.212000+00:00\", \"permalink\": \"https://www.reddit.com/r/<TEST_SUBREDDIT>/comments/z3wtr9/test_post/\", \"title\": \"Test post\"}, \"t3_z3wv0z\": {\"date\": \"2022-11-24T22:45:18.381000+00:00\", \"permalink\": \"https://www.reddit.com/r/<TEST_SUBREDDIT>/comments/z3wv0z/test_post/\", \"title\": \"Test post\"}, \"t3_z3x7gi\": {\"date\": \"2022-11-24T23:00:51.261000+00:00\", \"permalink\": \"https://www.reddit.com/r/<TEST_SUBREDDIT>/comments/z3x7gi/test_post/\", \"title\": \"Test post\"}, \"t3_z3x64t\": {\"date\": \"2022-11-24T22:59:35.632000+00:00\", \"permalink\": \"https://www.reddit.com/r/<TEST_SUBREDDIT>/comments/z3x64t/test_post/\", \"title\": \"Test post\"}, \"t3_14lt78w\": {\"date\": \"2023-06-29T02:57:46.846000+00:00\", \"permalink\": \"https://www.reddit.com/r/<TEST_SUBREDDIT>/comments/14lt78w/hi/\", \"title\": \"hi\"}}, \"recentConvos\": {\"fjhla\": {\"date\": \"2020-07-16T01:15:55.263000+0000\", \"permalink\": \"https://mod.reddit.com/mail/perma/fjhla\", \"id\": \"fjhla\", \"subject\": \"Spam\"}, \"1magps\": {\"date\": \"2023-07-11T20:18:46.102000+0000\", \"permalink\": \"https://mod.reddit.com/mail/perma/1magps\", \"id\": \"1magps\", \"subject\": \"test\"}, \"1magq3\": {\"date\": \"2023-07-11T20:28:57.787000+0000\", \"permalink\": \"https://mod.reddit.com/mail/perma/1magq3\", \"id\": \"1magq3\", \"subject\": \"test\"}, \"1l7pjk\": {\"date\": \"2023-06-25T17:16:07.135000+0000\", \"permalink\": \"https://mod.reddit.com/mail/perma/1l7pjk\", \"id\": \"1l7pjk\", \"subject\": \"invitation to moderate /r/<TEST_SUBREDDIT>\"}, \"1mahha\": {\"date\": \"2023-07-11T20:33:14.617000+0000\", \"permalink\": \"https://mod.reddit.com/mail/perma/1mahha\", \"id\": \"1mahha\", \"subject\": \"test\"}, \"19u06q\": {\"date\": \"2022-11-20T19:21:19.387000+0000\", \"permalink\": \"https://mod.reddit.com/mail/perma/19u06q\", \"id\": \"19u06q\", \"subject\": \"invitation to moderate /r/<TEST_SUBREDDIT>\"}, \"1mahgy\": {\"date\": \"2023-07-11T20:32:00.840000+0000\", \"permalink\": \"https://mod.reddit.com/mail/perma/1mahgy\", \"id\": \"1mahgy\", \"subject\": \"test\"}, \"fjhnq\": {\"date\": \"2020-07-16T01:15:07.219000+0000\", \"permalink\": \"https://mod.reddit.com/mail/perma/fjhnq\", \"id\": \"fjhnq\", \"subject\": \"Spam\"}}, \"id\": \"t2_75u2lqkb\"}, \"modActions\": {}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "5735" + ], + "Date": [ + "Tue, 11 Jul 2023 20:33:14 GMT" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 1.0, \"failure_fraction\": 1.0}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}, {\"group\": \"w3-reporting-csp\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-csp.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "content-type": [ + "application/json; charset=UTF-8" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=000000000075u2lqkb.2.1593898363221.Z0FBQUFBQmtyYnlLd2NOTXNkaDdPRzNNU3NVZkdtbVlKNndTaHk2bWs2NjI0NXlqdHZEZlhTWGVhWHU3UVBOODJ2Y28ydXJqNG5Ydll4a0ZqbGxrT3ZzWkl1d1QzUzdWLURhZnZSemsxSFNyeG1lMGlOSDM2NVF3akw1bHNpd3A0VnFPeEFxbjFzWWQ; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Thu, 10-Jul-2025 20:33:14 GMT; secure", + "session_tracker=coofkkigherfoqbqdh.0.1689107594576.Z0FBQUFBQmtyYnlLdGM1Q1lGb2xvbFJWMUlnNUlHWDN4MjFZdldXZUhLUEZmT3NEdVAxVy1YTzd0c2EzQjNsZ215SEpxYlRXdlhMU0o1UWlpbHZreTBGNUdvd1lEOGI2RWNzZmRmMktFTzQ1S1R4bG0xcVRIMmFfVHpGYnc3dXBoRHhEUmtkLTk3TGg; Domain=reddit.com; Max-Age=7199; Path=/; expires=Tue, 11-Jul-2023 22:33:14 GMT; secure" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "995" + ], + "x-ratelimit-reset": [ + "406" + ], + "x-ratelimit-used": [ + "1" + ] + }, + "status": { + "code": 201, + "message": "Created" + }, + "url": "https://oauth.reddit.com/api/mod/conversations/1mahha?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} diff --git a/tests/integration/models/reddit/test_modmail.py b/tests/integration/models/reddit/test_modmail.py index 88313df3..9875ff71 100644 --- a/tests/integration/models/reddit/test_modmail.py +++ b/tests/integration/models/reddit/test_modmail.py @@ -55,6 +55,12 @@ class TestModmailConversation(IntegrationTest): reply = conversation.reply(body="A message") assert isinstance(reply, ModmailMessage) + def test_reply__internal(self, reddit): + reddit.read_only = False + conversation = reddit.subreddit("all").modmail("1mahha") + reply = conversation.reply(internal=True, body="A message") + assert isinstance(reply, ModmailMessage) + def test_unarchive(self, reddit): reddit.read_only = False conversation = reddit.subreddit("all").modmail("ik72")
Modmail Conversations throw a TypeError when issuing a reply ### Describe the Bug A TypeError is thrown for a modmail conversation if leaving an internal reply. The code we've been using to do this has been in place for months; the first observed error was at 2023-07-10 14:16:32 UTC This appears to occur whether the reply is internal or to the user. It is worth noting that the reply goes through; the error occurs after submitting the reply. ### Desired Result A new modmail conversation is created, then an internal moderator note is left. ### Code to reproduce the bug ```Python testingSub = "" #your subreddit name testingUser = "" #the user you're sending the modmail to conversation = reddit.subreddit(testingSub).modmail.create(subject="test", body="testing", recipient=testingUser, author_hidden=True) conversation.reply(internal=True, body="additional test") #this is where the error happens ``` ### The `Reddit()` initialization in my code example does not include the following parameters to prevent credential leakage: `client_secret`, `password`, or `refresh_token`. - [X] Yes ### Relevant Logs ```Shell Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 4, in test File "/<redacted>/lib/python3.8/site-packages/praw/util/deprecate_args.py", line 43, in wrapped return func(**dict(zip(_old_args, args)), **kwargs) File "/<redacted>/lib/python3.8/site-packages/praw/models/reddit/modmail.py", line 265, in reply message_id = response["conversation"]["objIds"][-1]["id"] ``` ### This code has previously worked as intended. Yes ### Operating System/Environment Ubuntu 20.04.4 (WSL), almalinux8 ### Python Version 3.8.10, 3.9.13 ### PRAW Version 3.7 ### Prawcore Version 2.3.0 ### Anything else? _No response_
0.0
8bf669309a1476fa995f99c87c895fadf5436563
[ "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_reply__internal" ]
[ "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_archive", "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_highlight", "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_mute", "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_mute_duration", "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_read", "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_read__other_conversations", "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_reply", "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_unarchive", "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_unhighlight", "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_unmute", "tests/integration/models/reddit/test_modmail.py::TestModmailConversation::test_unread" ]
{ "failed_lite_validators": [ "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2023-07-11 20:39:06+00:00
bsd-2-clause
4,648
praw-dev__prawcore-90
diff --git a/AUTHORS.rst b/AUTHORS.rst index 20b5528..18dffc4 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -13,4 +13,5 @@ Contributors - elnuno `@elnuno <https://github.com/elnuno>`_ - Zeerak Waseem <[email protected]> `@ZeerakW <https://github.com/ZeerakW>`_ - jarhill0 `@jarhill0 <https://github.com/jarhill0>`_ +- Watchful1 `@Watchful1 <https://github.com/Watchful1>`_ - Add "Name <email (optional)> and github profile link" above this line. diff --git a/CHANGES.rst b/CHANGES.rst index 2f86871..9a380d0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,11 @@ that deprecations will not be announced by a minor release. Unreleased ---------- +**Changed** + +* Updated rate limit algorithm to more intelligently rate limit when there + are extra requests remaining. + **Removed** * Drop python 2.7 support. diff --git a/prawcore/rate_limit.py b/prawcore/rate_limit.py index b01c984..942852d 100644 --- a/prawcore/rate_limit.py +++ b/prawcore/rate_limit.py @@ -67,7 +67,6 @@ class RateLimiter(object): return now = time.time() - prev_remaining = self.remaining seconds_to_reset = int(response_headers["x-ratelimit-reset"]) self.remaining = float(response_headers["x-ratelimit-remaining"]) @@ -78,12 +77,7 @@ class RateLimiter(object): self.next_request_timestamp = self.reset_timestamp return - if prev_remaining is not None and prev_remaining > self.remaining: - estimated_clients = prev_remaining - self.remaining - else: - estimated_clients = 1.0 - self.next_request_timestamp = min( self.reset_timestamp, - now + (estimated_clients * seconds_to_reset / self.remaining), + now + max(min((seconds_to_reset - self.remaining) / 2, 10), 0), )
praw-dev/prawcore
accdd41f6a05f38a414c4ae5deebac441f2193fe
diff --git a/tests/test_rate_limit.py b/tests/test_rate_limit.py index 5833a4f..8f73a0c 100644 --- a/tests/test_rate_limit.py +++ b/tests/test_rate_limit.py @@ -70,22 +70,22 @@ class RateLimiterTest(unittest.TestCase): self.rate_limiter.update(self._headers(60, 100, 60)) self.assertEqual(60, self.rate_limiter.remaining) self.assertEqual(100, self.rate_limiter.used) - self.assertEqual(101, self.rate_limiter.next_request_timestamp) + self.assertEqual(100, self.rate_limiter.next_request_timestamp) @patch("time.time") def test_update__compute_delay_with_single_client(self, mock_time): self.rate_limiter.remaining = 61 mock_time.return_value = 100 - self.rate_limiter.update(self._headers(60, 100, 60)) - self.assertEqual(60, self.rate_limiter.remaining) + self.rate_limiter.update(self._headers(50, 100, 60)) + self.assertEqual(50, self.rate_limiter.remaining) self.assertEqual(100, self.rate_limiter.used) - self.assertEqual(101, self.rate_limiter.next_request_timestamp) + self.assertEqual(105, self.rate_limiter.next_request_timestamp) @patch("time.time") def test_update__compute_delay_with_six_clients(self, mock_time): self.rate_limiter.remaining = 66 mock_time.return_value = 100 - self.rate_limiter.update(self._headers(60, 100, 60)) + self.rate_limiter.update(self._headers(60, 100, 72)) self.assertEqual(60, self.rate_limiter.remaining) self.assertEqual(100, self.rate_limiter.used) self.assertEqual(106, self.rate_limiter.next_request_timestamp)
Rate limiting is overly conservative Currently the sleep time between requests is calculated based purely on the requests remaining and the seconds to reset, and doesn't take into account the time it takes for the request itself. As an example, my tests are averaging 0.65 seconds for the request itself to return. So right after the reset, with 600 requests and 600 seconds, praw will wait 1 second, then the request takes 0.65 seconds. If I hit the middle of the window, say 600 requests left and 300 seconds, it will wait 0.5 seconds, then the request takes 0.65 seconds, which still results in a total wait time of 1.15 seconds. So in 600 seconds you end up sending something like 350-400 requests. I think this should be changed to have no sleep time at all if the number of requests remaining is greater than the number of seconds until reset. Or possibly a bit of buffer, if the requests remaining is, say, more than 10 above the number of seconds until reset. Just to make sure there's no edge case where you end up waiting 10 seconds for something.
0.0
accdd41f6a05f38a414c4ae5deebac441f2193fe
[ "tests/test_rate_limit.py::RateLimiterTest::test_update__compute_delay_with_no_previous_info", "tests/test_rate_limit.py::RateLimiterTest::test_update__compute_delay_with_single_client", "tests/test_rate_limit.py::RateLimiterTest::test_update__compute_delay_with_six_clients" ]
[ "tests/test_rate_limit.py::RateLimiterTest::test_delay", "tests/test_rate_limit.py::RateLimiterTest::test_delay__no_sleep_when_time_in_past", "tests/test_rate_limit.py::RateLimiterTest::test_delay__no_sleep_when_time_is_not_set", "tests/test_rate_limit.py::RateLimiterTest::test_delay__no_sleep_when_times_match", "tests/test_rate_limit.py::RateLimiterTest::test_update__delay_full_time_with_negative_remaining", "tests/test_rate_limit.py::RateLimiterTest::test_update__delay_full_time_with_zero_remaining", "tests/test_rate_limit.py::RateLimiterTest::test_update__no_change_without_headers", "tests/test_rate_limit.py::RateLimiterTest::test_update__values_change_without_headers" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2020-04-13 05:31:24+00:00
bsd-2-clause
4,649
pre-commit__pre-commit-1299
diff --git a/pre_commit/commands/install_uninstall.py b/pre_commit/commands/install_uninstall.py index 9372176..b2ccc5c 100644 --- a/pre_commit/commands/install_uninstall.py +++ b/pre_commit/commands/install_uninstall.py @@ -123,7 +123,7 @@ def install( skip_on_missing_config: bool = False, git_dir: Optional[str] = None, ) -> int: - if git.has_core_hookpaths_set(): + if git_dir is None and git.has_core_hookpaths_set(): logger.error( 'Cowardly refusing to install hooks with `core.hooksPath` set.\n' 'hint: `git config --unset-all core.hooksPath`',
pre-commit/pre-commit
f74e3031bda69bc9b0f2a91ea83dc6e7a01e2986
diff --git a/tests/commands/init_templatedir_test.py b/tests/commands/init_templatedir_test.py index 4e32e75..d14a171 100644 --- a/tests/commands/init_templatedir_test.py +++ b/tests/commands/init_templatedir_test.py @@ -79,3 +79,14 @@ def test_init_templatedir_expanduser(tmpdir, tempdir_factory, store, cap_out): lines = cap_out.get().splitlines() assert len(lines) == 1 assert lines[0].startswith('pre-commit installed at') + + +def test_init_templatedir_hookspath_set(tmpdir, tempdir_factory, store): + target = tmpdir.join('tmpl') + tmp_git_dir = git_dir(tempdir_factory) + with cwd(tmp_git_dir): + cmd_output('git', 'config', '--local', 'core.hooksPath', 'hooks') + init_templatedir( + C.CONFIG_FILE, store, target, hook_types=['pre-commit'], + ) + assert target.join('hooks/pre-commit').exists()
core.hooksPath being set makes it not possible to install I have a laptop which has some mandaotry global settings for git, and I have not been able to enable pre-commit. I also tried doing ``` git config --global init.templateDir ~/.git-template pre-commit init-templatedir ~/.git-template ``` But still get the message ``` [ERROR] Cowardly refusing to install hooks with `core.hooksPath` set. hint: `git config --unset-all core.hooksPath` ``` Is there any work arounds for this?
0.0
f74e3031bda69bc9b0f2a91ea83dc6e7a01e2986
[ "tests/commands/init_templatedir_test.py::test_init_templatedir_hookspath_set" ]
[ "tests/commands/init_templatedir_test.py::test_init_templatedir_already_set", "tests/commands/init_templatedir_test.py::test_init_templatedir_not_set", "tests/commands/init_templatedir_test.py::test_init_templatedir_expanduser" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2020-01-28 20:43:51+00:00
mit
4,650
pre-commit__pre-commit-1364
diff --git a/pre_commit/error_handler.py b/pre_commit/error_handler.py index b095ba2..b2321ae 100644 --- a/pre_commit/error_handler.py +++ b/pre_commit/error_handler.py @@ -8,23 +8,15 @@ from typing import Generator import pre_commit.constants as C from pre_commit import output from pre_commit.store import Store +from pre_commit.util import force_bytes class FatalError(RuntimeError): pass -def _exception_to_bytes(exc: BaseException) -> bytes: - with contextlib.suppress(TypeError): - return bytes(exc) # type: ignore - with contextlib.suppress(Exception): - return str(exc).encode() - return f'<unprintable {type(exc).__name__} object>'.encode() - - def _log_and_exit(msg: str, exc: BaseException, formatted: str) -> None: - error_msg = f'{msg}: {type(exc).__name__}: '.encode() - error_msg += _exception_to_bytes(exc) + error_msg = f'{msg}: {type(exc).__name__}: '.encode() + force_bytes(exc) output.write_line_b(error_msg) log_path = os.path.join(Store().directory, 'pre-commit.log') output.write_line(f'Check the log at {log_path}') diff --git a/pre_commit/util.py b/pre_commit/util.py index 7da41c4..2db579a 100644 --- a/pre_commit/util.py +++ b/pre_commit/util.py @@ -43,6 +43,14 @@ def yaml_dump(o: Any) -> str: ) +def force_bytes(exc: Any) -> bytes: + with contextlib.suppress(TypeError): + return bytes(exc) + with contextlib.suppress(Exception): + return str(exc).encode() + return f'<unprintable {type(exc).__name__} object>'.encode() + + @contextlib.contextmanager def clean_path_on_failure(path: str) -> Generator[None, None, None]: """Cleans up the directory on an exceptional failure.""" @@ -120,6 +128,10 @@ def _setdefault_kwargs(kwargs: Dict[str, Any]) -> None: kwargs.setdefault(arg, subprocess.PIPE) +def _oserror_to_output(e: OSError) -> Tuple[int, bytes, None]: + return 1, force_bytes(e).rstrip(b'\n') + b'\n', None + + def cmd_output_b( *cmd: str, retcode: Optional[int] = 0, @@ -132,9 +144,13 @@ def cmd_output_b( except parse_shebang.ExecutableNotFoundError as e: returncode, stdout_b, stderr_b = e.to_output() else: - proc = subprocess.Popen(cmd, **kwargs) - stdout_b, stderr_b = proc.communicate() - returncode = proc.returncode + try: + proc = subprocess.Popen(cmd, **kwargs) + except OSError as e: + returncode, stdout_b, stderr_b = _oserror_to_output(e) + else: + stdout_b, stderr_b = proc.communicate() + returncode = proc.returncode if retcode is not None and retcode != returncode: raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b) @@ -205,7 +221,11 @@ if os.name != 'nt': # pragma: win32 no cover with open(os.devnull) as devnull, Pty() as pty: assert pty.r is not None kwargs.update({'stdin': devnull, 'stdout': pty.w, 'stderr': pty.w}) - proc = subprocess.Popen(cmd, **kwargs) + try: + proc = subprocess.Popen(cmd, **kwargs) + except OSError as e: + return _oserror_to_output(e) + pty.close_w() buf = b''
pre-commit/pre-commit
58a16bcf57b5da38f39885586832834858b71266
diff --git a/tests/util_test.py b/tests/util_test.py index 9f75f6a..01afbd4 100644 --- a/tests/util_test.py +++ b/tests/util_test.py @@ -9,6 +9,7 @@ from pre_commit.util import clean_path_on_failure from pre_commit.util import cmd_output from pre_commit.util import cmd_output_b from pre_commit.util import cmd_output_p +from pre_commit.util import make_executable from pre_commit.util import parse_version from pre_commit.util import rmtree from pre_commit.util import tmpdir @@ -92,6 +93,18 @@ def test_cmd_output_exe_not_found_bytes(fn): assert out == b'Executable `dne` not found' [email protected]('fn', (cmd_output_b, cmd_output_p)) +def test_cmd_output_no_shebang(tmpdir, fn): + f = tmpdir.join('f').ensure() + make_executable(f) + + # previously this raised `OSError` -- the output is platform specific + ret, out, _ = fn(str(f), retcode=None, stderr=subprocess.STDOUT) + assert ret == 1 + assert isinstance(out, bytes) + assert out.endswith(b'\n') + + def test_parse_version(): assert parse_version('0.0') == parse_version('0.0') assert parse_version('0.1') > parse_version('0.0')
"script" language without a shebang causes unexpected OSError Repro steps: Create a script hook. ``` - repo: local hooks: - id: foo name: foo language: script entry: foo.py types: [python] ``` `foo.py` can be empty. If foo.py is not executable, `pre-commit run foo --all-files` produces a reasonable error message: ``` foo......................................................................Failed - hook id: foo - exit code: 1 Executable `/[redacted]/foo.py` is not executable ``` However, if it is executable but doesn't not contain a shebang, you get ``` $ pre-commit run foo --all-files foo......................................................................An unexpected error has occurred: OSError: [Errno 8] Exec format error: '/[redacted]/foo.py' Check the log at /[redacted]/.cache/pre-commit/pre-commit.log ``` Log contents: ### version information ``` pre-commit version: 2.1.1 sys.version: 3.7.6 (default, Dec 30 2019, 19:38:28) [Clang 11.0.0 (clang-1100.0.33.16)] sys.executable: /[redacted]/venv/bin/python3 os.name: posix sys.platform: darwin ``` ### error information ``` An unexpected error has occurred: OSError: [Errno 8] Exec format error: '/[redacted]/foo.py' ``` ``` Traceback (most recent call last): File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/error_handler.py", line 54, in error_handler yield File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/main.py", line 371, in main return run(args.config, store, args) File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/commands/run.py", line 339, in run return _run_hooks(config, hooks, args, environ) File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/commands/run.py", line 249, in _run_hooks verbose=args.verbose, use_color=args.color, File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/commands/run.py", line 165, in _run_single_hook retcode, out = language.run_hook(hook, filenames, use_color) File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/languages/script.py", line 19, in run_hook return helpers.run_xargs(hook, cmd, file_args, color=color) File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/languages/helpers.py", line 109, in run_xargs return xargs(cmd, file_args, **kwargs) File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/xargs.py", line 153, in xargs for proc_retcode, proc_out, _ in results: File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 598, in result_iterator yield fs.pop().result() File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 428, in result return self.__get_result() File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result raise self._exception File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/xargs.py", line 146, in run_cmd_partition *run_cmd, retcode=None, stderr=subprocess.STDOUT, **kwargs, File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/util.py", line 208, in cmd_output_p proc = subprocess.Popen(cmd, **kwargs) File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 800, in __init__ restore_signals, start_new_session) File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) OSError: [Errno 8] Exec format error: '/[redacted]/foo.py' ```
0.0
58a16bcf57b5da38f39885586832834858b71266
[ "tests/util_test.py::test_cmd_output_no_shebang[cmd_output_b]", "tests/util_test.py::test_cmd_output_no_shebang[cmd_output_p]" ]
[ "tests/util_test.py::test_CalledProcessError_str", "tests/util_test.py::test_CalledProcessError_str_nooutput", "tests/util_test.py::test_clean_on_failure_noop", "tests/util_test.py::test_clean_path_on_failure_does_nothing_when_not_raising", "tests/util_test.py::test_clean_path_on_failure_cleans_for_normal_exception", "tests/util_test.py::test_clean_path_on_failure_cleans_for_system_exit", "tests/util_test.py::test_tmpdir", "tests/util_test.py::test_cmd_output_exe_not_found", "tests/util_test.py::test_cmd_output_exe_not_found_bytes[cmd_output_b]", "tests/util_test.py::test_cmd_output_exe_not_found_bytes[cmd_output_p]", "tests/util_test.py::test_parse_version", "tests/util_test.py::test_rmtree_read_only_directories" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2020-03-12 17:54:26+00:00
mit
4,651
pre-commit__pre-commit-1415
diff --git a/pre_commit/commands/hook_impl.py b/pre_commit/commands/hook_impl.py index 4843fc7..d0e226f 100644 --- a/pre_commit/commands/hook_impl.py +++ b/pre_commit/commands/hook_impl.py @@ -150,6 +150,7 @@ def _pre_push_ns( _EXPECTED_ARG_LENGTH_BY_HOOK = { 'commit-msg': 1, 'post-checkout': 3, + 'post-commit': 0, 'pre-commit': 0, 'pre-merge-commit': 0, 'pre-push': 2, @@ -186,7 +187,7 @@ def _run_ns( return _pre_push_ns(color, args, stdin) elif hook_type in {'commit-msg', 'prepare-commit-msg'}: return _ns(hook_type, color, commit_msg_filename=args[0]) - elif hook_type in {'pre-merge-commit', 'pre-commit'}: + elif hook_type in {'post-commit', 'pre-merge-commit', 'pre-commit'}: return _ns(hook_type, color) elif hook_type == 'post-checkout': return _ns( diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py index 8c8401c..8a9352d 100644 --- a/pre_commit/commands/run.py +++ b/pre_commit/commands/run.py @@ -221,7 +221,8 @@ def _compute_cols(hooks: Sequence[Hook]) -> int: def _all_filenames(args: argparse.Namespace) -> Collection[str]: - if args.hook_stage == 'post-checkout': # no files for post-checkout + # these hooks do not operate on files + if args.hook_stage in {'post-checkout', 'post-commit'}: return () elif args.hook_stage in {'prepare-commit-msg', 'commit-msg'}: return (args.commit_msg_filename,) diff --git a/pre_commit/constants.py b/pre_commit/constants.py index e2b8e3a..5150fdc 100644 --- a/pre_commit/constants.py +++ b/pre_commit/constants.py @@ -17,8 +17,8 @@ VERSION = importlib_metadata.version('pre_commit') # `manual` is not invoked by any installed git hook. See #719 STAGES = ( - 'commit', 'merge-commit', 'prepare-commit-msg', 'commit-msg', 'manual', - 'post-checkout', 'push', + 'commit', 'merge-commit', 'prepare-commit-msg', 'commit-msg', + 'post-commit', 'manual', 'post-checkout', 'push', ) DEFAULT = 'default' diff --git a/pre_commit/main.py b/pre_commit/main.py index 790b347..874eb53 100644 --- a/pre_commit/main.py +++ b/pre_commit/main.py @@ -79,7 +79,7 @@ def _add_hook_type_option(parser: argparse.ArgumentParser) -> None: parser.add_argument( '-t', '--hook-type', choices=( 'pre-commit', 'pre-merge-commit', 'pre-push', - 'prepare-commit-msg', 'commit-msg', 'post-checkout', + 'prepare-commit-msg', 'commit-msg', 'post-commit', 'post-checkout', ), action=AppendReplaceDefault, default=['pre-commit'],
pre-commit/pre-commit
3b3b33ea29ee11b10a41f237b1ced8c2a4b91592
diff --git a/tests/commands/hook_impl_test.py b/tests/commands/hook_impl_test.py index ddf65b7..cce4a25 100644 --- a/tests/commands/hook_impl_test.py +++ b/tests/commands/hook_impl_test.py @@ -96,6 +96,7 @@ def test_run_legacy_recursive(tmpdir): ('pre-merge-commit', []), ('pre-push', ['branch_name', 'remote_name']), ('commit-msg', ['.git/COMMIT_EDITMSG']), + ('post-commit', []), ('post-checkout', ['old_head', 'new_head', '1']), # multiple choices for commit-editmsg ('prepare-commit-msg', ['.git/COMMIT_EDITMSG']), @@ -149,6 +150,13 @@ def test_run_ns_commit_msg(): assert ns.commit_msg_filename == '.git/COMMIT_MSG' +def test_run_ns_post_commit(): + ns = hook_impl._run_ns('post-commit', True, (), b'') + assert ns is not None + assert ns.hook_stage == 'post-commit' + assert ns.color is True + + def test_run_ns_post_checkout(): ns = hook_impl._run_ns('post-checkout', True, ('a', 'b', 'c'), b'') assert ns is not None diff --git a/tests/commands/install_uninstall_test.py b/tests/commands/install_uninstall_test.py index 66b9190..6d75e68 100644 --- a/tests/commands/install_uninstall_test.py +++ b/tests/commands/install_uninstall_test.py @@ -726,6 +726,32 @@ def test_commit_msg_legacy(commit_msg_repo, tempdir_factory, store): assert second_line.startswith('Must have "Signed off by:"...') +def test_post_commit_integration(tempdir_factory, store): + path = git_dir(tempdir_factory) + config = [ + { + 'repo': 'local', + 'hooks': [{ + 'id': 'post-commit', + 'name': 'Post commit', + 'entry': 'touch post-commit.tmp', + 'language': 'system', + 'always_run': True, + 'verbose': True, + 'stages': ['post-commit'], + }], + }, + ] + write_config(path, config) + with cwd(path): + _get_commit_output(tempdir_factory) + assert not os.path.exists('post-commit.tmp') + + install(C.CONFIG_FILE, store, hook_types=['post-commit']) + _get_commit_output(tempdir_factory) + assert os.path.exists('post-commit.tmp') + + def test_post_checkout_integration(tempdir_factory, store): path = git_dir(tempdir_factory) config = [ diff --git a/tests/repository_test.py b/tests/repository_test.py index 3c7a637..f55c34c 100644 --- a/tests/repository_test.py +++ b/tests/repository_test.py @@ -880,7 +880,7 @@ def test_manifest_hooks(tempdir_factory, store): require_serial=False, stages=( 'commit', 'merge-commit', 'prepare-commit-msg', 'commit-msg', - 'manual', 'post-checkout', 'push', + 'post-commit', 'manual', 'post-checkout', 'push', ), types=['file'], verbose=False,
allow post-commit hook I would like to tag git versions whenever specific conditions are true. I can't use pre-commit because I don't have a commit yet, pre-push would lead to the new tag not being pushed together with the rest. Did I miss something or is this hook simply not added yet?
0.0
3b3b33ea29ee11b10a41f237b1ced8c2a4b91592
[ "tests/commands/hook_impl_test.py::test_check_args_length_ok[post-commit-args4]", "tests/commands/hook_impl_test.py::test_run_ns_post_commit" ]
[ "tests/commands/hook_impl_test.py::test_validate_config_file_exists", "tests/commands/hook_impl_test.py::test_validate_config_missing", "tests/commands/hook_impl_test.py::test_validate_config_skip_missing_config", "tests/commands/hook_impl_test.py::test_validate_config_skip_via_env_variable", "tests/commands/hook_impl_test.py::test_run_legacy_does_not_exist", "tests/commands/hook_impl_test.py::test_run_legacy_executes_legacy_script", "tests/commands/hook_impl_test.py::test_run_legacy_pre_push_returns_stdin", "tests/commands/hook_impl_test.py::test_run_legacy_recursive", "tests/commands/hook_impl_test.py::test_check_args_length_ok[pre-commit-args0]", "tests/commands/hook_impl_test.py::test_check_args_length_ok[pre-merge-commit-args1]", "tests/commands/hook_impl_test.py::test_check_args_length_ok[pre-push-args2]", "tests/commands/hook_impl_test.py::test_check_args_length_ok[commit-msg-args3]", "tests/commands/hook_impl_test.py::test_check_args_length_ok[post-checkout-args5]", "tests/commands/hook_impl_test.py::test_check_args_length_ok[prepare-commit-msg-args6]", "tests/commands/hook_impl_test.py::test_check_args_length_ok[prepare-commit-msg-args7]", "tests/commands/hook_impl_test.py::test_check_args_length_ok[prepare-commit-msg-args8]", "tests/commands/hook_impl_test.py::test_check_args_length_error_too_many_plural", "tests/commands/hook_impl_test.py::test_check_args_length_error_too_many_singluar", "tests/commands/hook_impl_test.py::test_check_args_length_prepare_commit_msg_error", "tests/commands/hook_impl_test.py::test_run_ns_pre_commit", "tests/commands/hook_impl_test.py::test_run_ns_commit_msg", "tests/commands/hook_impl_test.py::test_run_ns_post_checkout", "tests/commands/hook_impl_test.py::test_hook_impl_main_runs_hooks", "tests/commands/install_uninstall_test.py::test_is_not_script", "tests/commands/install_uninstall_test.py::test_is_script", "tests/commands/install_uninstall_test.py::test_is_previous_pre_commit", "tests/commands/install_uninstall_test.py::test_shebang_windows", "tests/commands/install_uninstall_test.py::test_shebang_posix_not_on_path", "tests/commands/install_uninstall_test.py::test_shebang_posix_on_path", "tests/commands/install_uninstall_test.py::test_install_pre_commit", "tests/commands/install_uninstall_test.py::test_install_hooks_directory_not_present", "tests/commands/install_uninstall_test.py::test_install_multiple_hooks_at_once", "tests/commands/install_uninstall_test.py::test_install_refuses_core_hookspath", "tests/commands/install_uninstall_test.py::test_install_hooks_dead_symlink", "tests/commands/install_uninstall_test.py::test_uninstall_does_not_blow_up_when_not_there", "tests/commands/install_uninstall_test.py::test_uninstall", "tests/commands/install_uninstall_test.py::test_uninstall_doesnt_remove_not_our_hooks", "tests/repository_test.py::test_grep_hook_matching", "tests/repository_test.py::test_grep_hook_case_insensitive", "tests/repository_test.py::test_grep_hook_not_matching[nope]", "tests/repository_test.py::test_grep_hook_not_matching[foo'bar]", "tests/repository_test.py::test_grep_hook_not_matching[^\\\\[INFO\\\\]]", "tests/repository_test.py::test_fail_hooks", "tests/repository_test.py::test_unknown_keys", "tests/repository_test.py::test_default_language_version", "tests/repository_test.py::test_default_stages" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2020-04-26 18:10:27+00:00
mit
4,652
pre-commit__pre-commit-1422
diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py index 8a9352d..c2dab6f 100644 --- a/pre_commit/commands/run.py +++ b/pre_commit/commands/run.py @@ -324,6 +324,12 @@ def run( f'`--hook-stage {args.hook_stage}`', ) return 1 + # prevent recursive post-checkout hooks (#1418) + if ( + args.hook_stage == 'post-checkout' and + environ.get('_PRE_COMMIT_SKIP_POST_CHECKOUT') + ): + return 0 # Expose from-ref / to-ref as environment variables for hooks to consume if args.from_ref and args.to_ref: diff --git a/pre_commit/staged_files_only.py b/pre_commit/staged_files_only.py index 09d323d..6179301 100644 --- a/pre_commit/staged_files_only.py +++ b/pre_commit/staged_files_only.py @@ -56,8 +56,10 @@ def _unstaged_changes_cleared(patch_dir: str) -> Generator[None, None, None]: with open(patch_filename, 'wb') as patch_file: patch_file.write(diff_stdout_binary) - # Clear the working directory of unstaged changes - cmd_output_b('git', 'checkout', '--', '.') + # prevent recursive post-checkout hooks (#1418) + no_checkout_env = dict(os.environ, _PRE_COMMIT_SKIP_POST_CHECKOUT='1') + cmd_output_b('git', 'checkout', '--', '.', env=no_checkout_env) + try: yield finally: @@ -72,8 +74,9 @@ def _unstaged_changes_cleared(patch_dir: str) -> Generator[None, None, None]: # We failed to apply the patch, presumably due to fixes made # by hooks. # Roll back the changes made by hooks. - cmd_output_b('git', 'checkout', '--', '.') + cmd_output_b('git', 'checkout', '--', '.', env=no_checkout_env) _git_apply(patch_filename) + logger.info(f'Restored changes from {patch_filename}.') else: # There weren't any staged files so we don't need to do anything
pre-commit/pre-commit
5ed3f5649bce212ddf93ac741c1378cb82b13ccc
diff --git a/testing/util.py b/testing/util.py index 439bee7..19500f6 100644 --- a/testing/util.py +++ b/testing/util.py @@ -103,10 +103,12 @@ def cwd(path): os.chdir(original_cwd) -def git_commit(*args, fn=cmd_output, msg='commit!', **kwargs): +def git_commit(*args, fn=cmd_output, msg='commit!', all_files=True, **kwargs): kwargs.setdefault('stderr', subprocess.STDOUT) - cmd = ('git', 'commit', '--allow-empty', '--no-gpg-sign', '-a') + args + cmd = ('git', 'commit', '--allow-empty', '--no-gpg-sign', *args) + if all_files: # allow skipping `-a` with `all_files=False` + cmd += ('-a',) if msg is not None: # allow skipping `-m` with `msg=None` cmd += ('-m', msg) ret, out, _ = fn(*cmd, **kwargs) diff --git a/tests/commands/install_uninstall_test.py b/tests/commands/install_uninstall_test.py index 6d75e68..5809a3f 100644 --- a/tests/commands/install_uninstall_test.py +++ b/tests/commands/install_uninstall_test.py @@ -789,6 +789,37 @@ def test_post_checkout_integration(tempdir_factory, store): assert 'some_file' not in stderr +def test_skips_post_checkout_unstaged_changes(tempdir_factory, store): + path = git_dir(tempdir_factory) + config = { + 'repo': 'local', + 'hooks': [{ + 'id': 'fail', + 'name': 'fail', + 'entry': 'fail', + 'language': 'fail', + 'always_run': True, + 'stages': ['post-checkout'], + }], + } + write_config(path, config) + with cwd(path): + cmd_output('git', 'add', '.') + _get_commit_output(tempdir_factory) + + install(C.CONFIG_FILE, store, hook_types=['pre-commit']) + install(C.CONFIG_FILE, store, hook_types=['post-checkout']) + + # make an unstaged change so staged_files_only fires + open('file', 'a').close() + cmd_output('git', 'add', 'file') + with open('file', 'w') as f: + f.write('unstaged changes') + + retc, out = _get_commit_output(tempdir_factory, all_files=False) + assert retc == 0 + + def test_prepare_commit_msg_integration_failing( failing_prepare_commit_msg_repo, tempdir_factory, store, ): diff --git a/tests/commands/run_test.py b/tests/commands/run_test.py index c51bcff..2fffdb9 100644 --- a/tests/commands/run_test.py +++ b/tests/commands/run_test.py @@ -1022,3 +1022,9 @@ def test_args_hook_only(cap_out, store, repo_with_passing_hook): run_opts(hook='do_not_commit'), ) assert b'identity-copy' not in printed + + +def test_skipped_without_any_setup_for_post_checkout(in_git_dir, store): + environ = {'_PRE_COMMIT_SKIP_POST_CHECKOUT': '1'} + opts = run_opts(hook_stage='post-checkout') + assert run(C.CONFIG_FILE, store, opts, environ=environ) == 0
post-checkout hook prevents pre-commit hooks from working with unstaged files Hi there! Most important thing first: pre-commit is great, it makes managing git hooks trivial and when combined with static analysis hooks, helps our team immeasurably - **thanks for all the hard work**. We have pre-commit hooks that run a bunch of checks, and thanks to #1339, a post-checkout hook that does some workspace analysis and prints a few warnings if needed. Unfortunately this seems to have broken the "stash unstaged changes" behaviour when committing - the stash [runs a git checkout](https://github.com/pre-commit/pre-commit/blob/5a625013071877a5b5dc8eba5b25c791c9c9c6ec/pre_commit/staged_files_only.py#L60) to clear the working directory before running the hooks, and that fails because of the post-checkout hook. I'd expect that the working directory to be cleared as normal, commit OK and then the working directory to be restored as it does without the post-checkout hook, as the actual mechanism behind removing the unstaged changes and restoring them is hidden from the user. Below is a quick test to reproduce it: ```bash #!/usr/bin/env bash mkdir test cd test || exit git init # Configure a pre-commit and post-checkout hook cat << EOF > .pre-commit-config.yaml repos: - repo: local hooks: - id: pre-commit-ok name: Pre-commit hook that always passes stages: [commit] language: system entry: sh -c 'exit 0' always_run: true - repo: local hooks: - id: post-checkout-fail name: Post-checkout hook that fails stages: [post-checkout] language: system entry: sh -c 'exit 1' always_run: true EOF echo "bananas" > great-things.txt git add . git commit -m "init" # Install the hooks pre-commit install -t pre-commit pre-commit install -t post-checkout # Do a checkout - this is expected to print an error from the lint git checkout -b test # Change the original file echo "platanos" >> great-things.txt # Add another file and stage it echo "42" > answer.txt git add answer.txt # Attempt to commit the new, staged file. # # Without the post-checkout hook, this causes the unstaged changes to be # stashed and the commit works as normal. echo "" echo "" echo " Attempting to commit with unstaged changes" echo " This will fail when attempting to checkout as part of the commit hook:" echo "" echo "" git commit -m "more info" ``` Unfortunately there seems to be no easy way to skip the post-checkout hook when clearing the unstaged files with `git checkout`. Happy to open a PR to help fix this, just unsure what to do - I could swap the `git checkout` for a `git stash save --keep-index --include-untracked` but I assume it is using checkout for reason.
0.0
5ed3f5649bce212ddf93ac741c1378cb82b13ccc
[ "tests/commands/run_test.py::test_skipped_without_any_setup_for_post_checkout" ]
[ "tests/commands/install_uninstall_test.py::test_is_not_script", "tests/commands/install_uninstall_test.py::test_is_script", "tests/commands/install_uninstall_test.py::test_is_previous_pre_commit", "tests/commands/install_uninstall_test.py::test_shebang_windows", "tests/commands/install_uninstall_test.py::test_shebang_posix_not_on_path", "tests/commands/install_uninstall_test.py::test_shebang_posix_on_path", "tests/commands/install_uninstall_test.py::test_install_pre_commit", "tests/commands/install_uninstall_test.py::test_install_hooks_directory_not_present", "tests/commands/install_uninstall_test.py::test_install_multiple_hooks_at_once", "tests/commands/install_uninstall_test.py::test_install_refuses_core_hookspath", "tests/commands/install_uninstall_test.py::test_install_hooks_dead_symlink", "tests/commands/install_uninstall_test.py::test_uninstall_does_not_blow_up_when_not_there", "tests/commands/install_uninstall_test.py::test_uninstall", "tests/commands/install_uninstall_test.py::test_uninstall_doesnt_remove_not_our_hooks", "tests/commands/run_test.py::test_start_msg", "tests/commands/run_test.py::test_full_msg", "tests/commands/run_test.py::test_full_msg_with_cjk", "tests/commands/run_test.py::test_full_msg_with_color", "tests/commands/run_test.py::test_full_msg_with_postfix", "tests/commands/run_test.py::test_full_msg_postfix_not_colored", "tests/commands/run_test.py::test_compute_cols[hooks0-80]", "tests/commands/run_test.py::test_compute_cols[hooks1-81]", "tests/commands/run_test.py::test_compute_cols[hooks2-82]", "tests/commands/run_test.py::test_get_skips[environ0-expected_output0]", "tests/commands/run_test.py::test_get_skips[environ1-expected_output1]", "tests/commands/run_test.py::test_get_skips[environ2-expected_output2]", "tests/commands/run_test.py::test_get_skips[environ3-expected_output3]", "tests/commands/run_test.py::test_get_skips[environ4-expected_output4]", "tests/commands/run_test.py::test_get_skips[environ5-expected_output5]", "tests/commands/run_test.py::test_get_skips[environ6-expected_output6]", "tests/commands/run_test.py::test_classifier_removes_dne", "tests/commands/run_test.py::test_classifier_normalizes_filenames_on_windows_to_forward_slashes", "tests/commands/run_test.py::test_classifier_does_not_normalize_backslashes_non_windows", "tests/commands/run_test.py::test_include_exclude_base_case", "tests/commands/run_test.py::test_matches_broken_symlink", "tests/commands/run_test.py::test_include_exclude_total_match", "tests/commands/run_test.py::test_include_exclude_does_search_instead_of_match", "tests/commands/run_test.py::test_include_exclude_exclude_removes_files" ]
{ "failed_lite_validators": [ "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2020-04-29 15:52:10+00:00
mit
4,653
pre-commit__pre-commit-1448
diff --git a/pre_commit/commands/migrate_config.py b/pre_commit/commands/migrate_config.py index d83b8e9..d580ff1 100644 --- a/pre_commit/commands/migrate_config.py +++ b/pre_commit/commands/migrate_config.py @@ -2,6 +2,7 @@ import re import yaml +from pre_commit.clientlib import load_config from pre_commit.util import yaml_load @@ -43,6 +44,9 @@ def _migrate_sha_to_rev(contents: str) -> str: def migrate_config(config_file: str, quiet: bool = False) -> int: + # ensure that the configuration is a valid pre-commit configuration + load_config(config_file) + with open(config_file) as f: orig_contents = contents = f.read()
pre-commit/pre-commit
46f5cc960947dc0b348a2b19db74e9ac0d5cecf6
diff --git a/tests/commands/migrate_config_test.py b/tests/commands/migrate_config_test.py index efc0d1c..6a049d5 100644 --- a/tests/commands/migrate_config_test.py +++ b/tests/commands/migrate_config_test.py @@ -1,6 +1,7 @@ import pytest import pre_commit.constants as C +from pre_commit.clientlib import InvalidConfigError from pre_commit.commands.migrate_config import _indent from pre_commit.commands.migrate_config import migrate_config @@ -147,10 +148,10 @@ def test_migrate_config_sha_to_rev(tmpdir): @pytest.mark.parametrize('contents', ('', '\n')) -def test_empty_configuration_file_user_error(tmpdir, contents): +def test_migrate_config_invalid_configuration(tmpdir, contents): cfg = tmpdir.join(C.CONFIG_FILE) cfg.write(contents) - with tmpdir.as_cwd(): - assert not migrate_config(C.CONFIG_FILE) + with tmpdir.as_cwd(), pytest.raises(InvalidConfigError): + migrate_config(C.CONFIG_FILE) # even though the config is invalid, this should be a noop assert cfg.read() == contents
Unhandled yaml.scanner.ScannerError when trying autoupdate with a malformed pre-commit config In migrate_config.py we catch `yaml.YAMLError` on [lines 31-36](https://github.com/pre-commit/pre-commit/blob/master/pre_commit/commands/migrate_config.py#L31-L36) (of which `yaml.scanner.ScannerError` is a subclass), but when the exception is raised on line 28, it is unhandled. ```console $ pre-commit autoupdate An unexpected error has occurred: ScannerError: mapping values are not allowed in this context in "<unicode string>", line 2, column 6 Check the log at /home/ryan/.cache/pre-commit/pre-commit.log ``` ### version information ``` pre-commit version: 2.3.0 sys.version: 3.8.2 (default, Apr 8 2020, 14:31:25) [GCC 9.3.0] sys.executable: /home/ryan/.local/pipx/venvs/pre-commit/bin/python os.name: posix sys.platform: linux ``` ### error information ``` An unexpected error has occurred: ScannerError: mapping values are not allowed in this context in "<unicode string>", line 2, column 6 ``` ``` Traceback (most recent call last): File "/home/ryan/.local/pipx/venvs/pre-commit/lib/python3.8/site-packages/pre_commit/error_handler.py", line 56, in error_handler yield File "/home/ryan/.local/pipx/venvs/pre-commit/lib/python3.8/site-packages/pre_commit/main.py", line 354, in main return autoupdate( File "/home/ryan/.local/pipx/venvs/pre-commit/lib/python3.8/site-packages/pre_commit/commands/autoupdate.py", line 141, in autoupdate migrate_config(config_file, quiet=True) File "/home/ryan/.local/pipx/venvs/pre-commit/lib/python3.8/site-packages/pre_commit/commands/migrate_config.py", line 49, in migrate_config contents = _migrate_map(contents) File "/home/ryan/.local/pipx/venvs/pre-commit/lib/python3.8/site-packages/pre_commit/commands/migrate_config.py", line 28, in _migrate_map if isinstance(yaml_load(contents), list): File "/home/ryan/.local/pipx/venvs/pre-commit/lib/python3.8/site-packages/yaml/__init__.py", line 114, in load return loader.get_single_data() File "/home/ryan/.local/pipx/venvs/pre-commit/lib/python3.8/site-packages/yaml/constructor.py", line 49, in get_single_data node = self.get_single_node() File "ext/_yaml.pyx", line 707, in _yaml.CParser.get_single_node File "ext/_yaml.pyx", line 726, in _yaml.CParser._compose_document File "ext/_yaml.pyx", line 905, in _yaml.CParser._parse_next_event yaml.scanner.ScannerError: mapping values are not allowed in this context in "<unicode string>", line 2, column 6 ```
0.0
46f5cc960947dc0b348a2b19db74e9ac0d5cecf6
[ "tests/commands/migrate_config_test.py::test_migrate_config_invalid_configuration[]", "tests/commands/migrate_config_test.py::test_migrate_config_invalid_configuration[\\n]" ]
[ "tests/commands/migrate_config_test.py::test_indent[-]", "tests/commands/migrate_config_test.py::test_indent[a-", "tests/commands/migrate_config_test.py::test_indent[foo\\nbar-", "tests/commands/migrate_config_test.py::test_indent[foo\\n\\nbar\\n-", "tests/commands/migrate_config_test.py::test_indent[\\n\\n\\n-\\n\\n\\n]", "tests/commands/migrate_config_test.py::test_migrate_config_normal_format", "tests/commands/migrate_config_test.py::test_migrate_config_document_marker", "tests/commands/migrate_config_test.py::test_migrate_config_list_literal", "tests/commands/migrate_config_test.py::test_already_migrated_configuration_noop", "tests/commands/migrate_config_test.py::test_migrate_config_sha_to_rev" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2020-05-11 01:04:04+00:00
mit
4,654
pre-commit__pre-commit-1707
diff --git a/pre_commit/clientlib.py b/pre_commit/clientlib.py index 0b8582b..d619ea5 100644 --- a/pre_commit/clientlib.py +++ b/pre_commit/clientlib.py @@ -112,6 +112,18 @@ LOCAL = 'local' META = 'meta' +class OptionalSensibleRegex(cfgv.OptionalNoDefault): + def check(self, dct: Dict[str, Any]) -> None: + super().check(dct) + + if '/*' in dct.get(self.key, ''): + logger.warning( + f'The {self.key!r} field in hook {dct.get("id")!r} is a ' + f"regex, not a glob -- matching '/*' probably isn't what you " + f'want here', + ) + + class MigrateShaToRev: key = 'rev' @@ -227,6 +239,8 @@ CONFIG_HOOK_DICT = cfgv.Map( for item in MANIFEST_HOOK_DICT.items if item.key != 'id' ), + OptionalSensibleRegex('files', cfgv.check_string), + OptionalSensibleRegex('exclude', cfgv.check_string), ) CONFIG_REPO_DICT = cfgv.Map( 'Repository', 'repo',
pre-commit/pre-commit
6e37f197b070e6d4ec2a59bd12d94ed7dd1f5374
diff --git a/tests/clientlib_test.py b/tests/clientlib_test.py index 2e2f738..bfb754b 100644 --- a/tests/clientlib_test.py +++ b/tests/clientlib_test.py @@ -166,6 +166,23 @@ def test_validate_warn_on_unknown_keys_at_top_level(tmpdir, caplog): ] +def test_validate_optional_sensible_regex(caplog): + config_obj = { + 'id': 'flake8', + 'files': 'dir/*.py', + } + cfgv.validate(config_obj, CONFIG_HOOK_DICT) + + assert caplog.record_tuples == [ + ( + 'pre_commit', + logging.WARNING, + "The 'files' field in hook 'flake8' is a regex, not a glob -- " + "matching '/*' probably isn't what you want here", + ), + ] + + @pytest.mark.parametrize('fn', (validate_config_main, validate_manifest_main)) def test_mains_not_ok(tmpdir, fn): not_yaml = tmpdir.join('f.notyaml')
Add warning for `files` / `exclude` containing `/*` it's a common mistake to believe that those fields are globs, they're not -- they're regular expressions. (and matching `/*` is nonsense, it matches `''`, `'/'` as well as `'//////////////////////////////////////////////////////'`
0.0
6e37f197b070e6d4ec2a59bd12d94ed7dd1f5374
[ "tests/clientlib_test.py::test_validate_optional_sensible_regex" ]
[ "tests/clientlib_test.py::test_check_type_tag_failures[definitely-not-a-tag]", "tests/clientlib_test.py::test_check_type_tag_failures[fiel]", "tests/clientlib_test.py::test_check_type_tag_success", "tests/clientlib_test.py::test_config_valid[config_obj0-True]", "tests/clientlib_test.py::test_config_valid[config_obj1-True]", "tests/clientlib_test.py::test_config_valid[config_obj2-False]", "tests/clientlib_test.py::test_local_hooks_with_rev_fails", "tests/clientlib_test.py::test_config_with_local_hooks_definition_passes", "tests/clientlib_test.py::test_config_schema_does_not_contain_defaults", "tests/clientlib_test.py::test_validate_manifest_main_ok", "tests/clientlib_test.py::test_validate_config_main_ok", "tests/clientlib_test.py::test_validate_config_old_list_format_ok", "tests/clientlib_test.py::test_validate_warn_on_unknown_keys_at_repo_level", "tests/clientlib_test.py::test_validate_warn_on_unknown_keys_at_top_level", "tests/clientlib_test.py::test_mains_not_ok[validate_config_main]", "tests/clientlib_test.py::test_mains_not_ok[validate_manifest_main]", "tests/clientlib_test.py::test_valid_manifests[manifest_obj0-True]", "tests/clientlib_test.py::test_valid_manifests[manifest_obj1-True]", "tests/clientlib_test.py::test_valid_manifests[manifest_obj2-True]", "tests/clientlib_test.py::test_migrate_sha_to_rev_ok[dct0]", "tests/clientlib_test.py::test_migrate_sha_to_rev_ok[dct1]", "tests/clientlib_test.py::test_migrate_sha_to_rev_ok[dct2]", "tests/clientlib_test.py::test_migrate_sha_to_rev_ok[dct3]", "tests/clientlib_test.py::test_migrate_sha_to_rev_dont_specify_both", "tests/clientlib_test.py::test_migrate_sha_to_rev_conditional_check_failures[dct0]", "tests/clientlib_test.py::test_migrate_sha_to_rev_conditional_check_failures[dct1]", "tests/clientlib_test.py::test_migrate_sha_to_rev_conditional_check_failures[dct2]", "tests/clientlib_test.py::test_migrate_to_sha_apply_default", "tests/clientlib_test.py::test_migrate_to_sha_ok", "tests/clientlib_test.py::test_meta_hook_invalid[config_repo0]", "tests/clientlib_test.py::test_meta_hook_invalid[config_repo1]", "tests/clientlib_test.py::test_meta_hook_invalid[config_repo2]", "tests/clientlib_test.py::test_default_language_version_invalid[mapping0]", "tests/clientlib_test.py::test_default_language_version_invalid[mapping1]", "tests/clientlib_test.py::test_minimum_pre_commit_version_failing", "tests/clientlib_test.py::test_minimum_pre_commit_version_passing", "tests/clientlib_test.py::test_warn_additional[schema0]", "tests/clientlib_test.py::test_warn_additional[schema1]" ]
{ "failed_lite_validators": [ "has_short_problem_statement" ], "has_test_patch": true, "is_lite": false }
2020-11-21 22:40:56+00:00
mit
4,655
pre-commit__pre-commit-hooks-1031
diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 4b4d0cf..116392d 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -40,6 +40,11 @@ language: python types: [text, executable] stages: [commit, push, manual] +- id: check-illegal-windows-names + name: check illegal windows names + entry: Illegal windows filenames detected + language: fail + files: '(?i)(^|/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|/|$)' - id: check-json name: check json description: checks json files for parseable syntax. diff --git a/README.md b/README.md index 4992baf..97bfba6 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,9 @@ Checks for a common error of placing code before the docstring. #### `check-executables-have-shebangs` Checks that non-binary executables have a proper shebang. +#### `check-illegal-windows-names` +Check for files that cannot be created on Windows. + #### `check-json` Attempts to load all json files to verify syntax.
pre-commit/pre-commit-hooks
b73acb198e5419f08c12c893b1a41bd847b41860
diff --git a/tests/check_illegal_windows_names_test.py b/tests/check_illegal_windows_names_test.py new file mode 100644 index 0000000..4dce4f6 --- /dev/null +++ b/tests/check_illegal_windows_names_test.py @@ -0,0 +1,46 @@ +from __future__ import annotations + +import os.path +import re + +import pytest + +from pre_commit_hooks.check_yaml import yaml + + [email protected](scope='module') +def hook_re(): + here = os.path.dirname(__file__) + with open(os.path.join(here, '..', '.pre-commit-hooks.yaml')) as f: + hook_defs = yaml.load(f) + hook, = ( + hook + for hook in hook_defs + if hook['id'] == 'check-illegal-windows-names' + ) + yield re.compile(hook['files']) + + [email protected]( + 's', + ( + pytest.param('aux.txt', id='with ext'), + pytest.param('aux', id='without ext'), + pytest.param('AuX.tXt', id='capitals'), + pytest.param('com7.dat', id='com with digit'), + ), +) +def test_check_illegal_windows_names_matches(hook_re, s): + assert hook_re.search(s) + + [email protected]( + 's', + ( + pytest.param('README.md', id='standard file'), + pytest.param('foo.aux', id='as ext'), + pytest.param('com.dat', id='com without digit'), + ), +) +def test_check_illegal_windows_names_does_not_match(hook_re, s): + assert hook_re.search(s) is None
Add check for illegal Windows filenames There are file and directory names which are legal in Git and most operating systems but illegal in Windows. They should be avoided in case a developer happens to use Windows. The following names are illegal as bare names as well as with extensions regardless of case for files or directories. For instance `CoM6`, `cOm6.txt`, `com6.foo.jpg`, etc are all illegal. Windows will refuse to create those files if you try to check them out. From: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file > Do not use the following reserved names for the name of a file: > > CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended. For more information, see [Namespaces](https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file).
0.0
b73acb198e5419f08c12c893b1a41bd847b41860
[ "tests/check_illegal_windows_names_test.py::test_check_illegal_windows_names_matches[with", "tests/check_illegal_windows_names_test.py::test_check_illegal_windows_names_matches[without", "tests/check_illegal_windows_names_test.py::test_check_illegal_windows_names_matches[capitals]", "tests/check_illegal_windows_names_test.py::test_check_illegal_windows_names_matches[com", "tests/check_illegal_windows_names_test.py::test_check_illegal_windows_names_does_not_match[standard", "tests/check_illegal_windows_names_test.py::test_check_illegal_windows_names_does_not_match[as", "tests/check_illegal_windows_names_test.py::test_check_illegal_windows_names_does_not_match[com" ]
[]
{ "failed_lite_validators": [ "has_hyperlinks", "has_media", "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2024-03-26 20:36:27+00:00
mit
4,656
pre-commit__pre-commit-hooks-1039
diff --git a/pre_commit_hooks/pretty_format_json.py b/pre_commit_hooks/pretty_format_json.py index 627a11c..5c0292b 100644 --- a/pre_commit_hooks/pretty_format_json.py +++ b/pre_commit_hooks/pretty_format_json.py @@ -115,16 +115,20 @@ def main(argv: Sequence[str] | None = None) -> int: f'Input File {json_file} is not a valid JSON, consider using ' f'check-json', ) - return 1 - - if contents != pretty_contents: - if args.autofix: - _autofix(json_file, pretty_contents) - else: - diff_output = get_diff(contents, pretty_contents, json_file) - sys.stdout.buffer.write(diff_output.encode()) - status = 1 + else: + if contents != pretty_contents: + if args.autofix: + _autofix(json_file, pretty_contents) + else: + diff_output = get_diff( + contents, + pretty_contents, + json_file, + ) + sys.stdout.buffer.write(diff_output.encode()) + + status = 1 return status
pre-commit/pre-commit-hooks
8c24e2c2e6b964feb04e1a93a72200ee84bd115a
diff --git a/tests/pretty_format_json_test.py b/tests/pretty_format_json_test.py index 5ded724..68b6d7a 100644 --- a/tests/pretty_format_json_test.py +++ b/tests/pretty_format_json_test.py @@ -82,6 +82,24 @@ def test_autofix_main(tmpdir): assert ret == 0 +def test_invalid_main(tmpdir): + srcfile1 = tmpdir.join('not_valid_json.json') + srcfile1.write( + '{\n' + ' // not json\n' + ' "a": "b"\n' + '}', + ) + srcfile2 = tmpdir.join('to_be_json_formatted.json') + srcfile2.write('{ "a": "b" }') + + # it should have skipped the first file and formatted the second one + assert main(['--autofix', str(srcfile1), str(srcfile2)]) == 1 + + # confirm second file was formatted (shouldn't trigger linter again) + assert main([str(srcfile2)]) == 0 + + def test_orderfile_get_pretty_format(): ret = main(( '--top-keys=alist', get_resource_path('pretty_formatted_json.json'),
`pretty-format-json` stops formatting JSONs when it encounters one with incorrect format (e.g. JSON5 comments) Transferred from https://github.com/pre-commit/pre-commit/issues/3124. `pretty-format-json` prints "Input File {json_file} is not a valid JSON, consider using check-json" when it encounters an incorrectly formatted JSON file (e.g. with JSON5 comments), but it's not clear from that message that it then stops further processing files. As `pre-commit` can partition the processed files into batches, this makes it even harder to tell as multiple batches of files can fail midway through with a few "X is not a valid JSON" messages printed, giving the impression that all the JSONs were formatted (or attempted formatted) and only those files printed are incorrect. The reality is that some JSONs may not have been formatted. I think this hook should try to format every JSON and only fail at the end if any have an invalid JSON format.
0.0
8c24e2c2e6b964feb04e1a93a72200ee84bd115a
[ "tests/pretty_format_json_test.py::test_invalid_main" ]
[ "tests/pretty_format_json_test.py::test_parse_num_to_int", "tests/pretty_format_json_test.py::test_main[not_pretty_formatted_json.json-1]", "tests/pretty_format_json_test.py::test_main[unsorted_pretty_formatted_json.json-1]", "tests/pretty_format_json_test.py::test_main[non_ascii_pretty_formatted_json.json-1]", "tests/pretty_format_json_test.py::test_main[pretty_formatted_json.json-0]", "tests/pretty_format_json_test.py::test_unsorted_main[not_pretty_formatted_json.json-1]", "tests/pretty_format_json_test.py::test_unsorted_main[unsorted_pretty_formatted_json.json-0]", "tests/pretty_format_json_test.py::test_unsorted_main[non_ascii_pretty_formatted_json.json-1]", "tests/pretty_format_json_test.py::test_unsorted_main[pretty_formatted_json.json-0]", "tests/pretty_format_json_test.py::test_tab_main[not_pretty_formatted_json.json-1]", "tests/pretty_format_json_test.py::test_tab_main[unsorted_pretty_formatted_json.json-1]", "tests/pretty_format_json_test.py::test_tab_main[non_ascii_pretty_formatted_json.json-1]", "tests/pretty_format_json_test.py::test_tab_main[pretty_formatted_json.json-1]", "tests/pretty_format_json_test.py::test_tab_main[tab_pretty_formatted_json.json-0]", "tests/pretty_format_json_test.py::test_non_ascii_main", "tests/pretty_format_json_test.py::test_autofix_main", "tests/pretty_format_json_test.py::test_orderfile_get_pretty_format", "tests/pretty_format_json_test.py::test_not_orderfile_get_pretty_format", "tests/pretty_format_json_test.py::test_top_sorted_get_pretty_format", "tests/pretty_format_json_test.py::test_badfile_main", "tests/pretty_format_json_test.py::test_diffing_output" ]
{ "failed_lite_validators": [ "has_hyperlinks" ], "has_test_patch": true, "is_lite": false }
2024-04-12 20:22:24+00:00
mit
4,657
pre-commit__pre-commit-hooks-111
diff --git a/README.md b/README.md index 091a8a4..6c3a3ec 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,8 @@ Add this to your `.pre-commit-config.yaml` - `double-quote-string-fixer` - This hook replaces double quoted strings with single quoted strings. - `end-of-file-fixer` - Makes sure files end in a newline and only a newline. -- `fix-encoding-pragma` - Add `# -*- coding: utf-8 -*-` to the top of python files +- `fix-encoding-pragma` - Add `# -*- coding: utf-8 -*-` to the top of python files. + - To remove the coding pragma pass `--remove` (useful in a python3-only codebase) - `flake8` - Run flake8 on your python files. - `name-tests-test` - Assert that files in tests/ end in `_test.py`. - Use `args: ['--django']` to match `test*.py` instead. diff --git a/pre_commit_hooks/fix_encoding_pragma.py b/pre_commit_hooks/fix_encoding_pragma.py index 48fc9c7..8586937 100644 --- a/pre_commit_hooks/fix_encoding_pragma.py +++ b/pre_commit_hooks/fix_encoding_pragma.py @@ -3,7 +3,7 @@ from __future__ import print_function from __future__ import unicode_literals import argparse -import io +import collections expected_pragma = b'# -*- coding: utf-8 -*-\n' @@ -21,34 +21,72 @@ def has_coding(line): ) -def fix_encoding_pragma(f): - first_line = f.readline() - second_line = f.readline() - old = f.read() - f.seek(0) +class ExpectedContents(collections.namedtuple( + 'ExpectedContents', ('shebang', 'rest', 'pragma_status'), +)): + """ + pragma_status: + - True: has exactly the coding pragma expected + - False: missing coding pragma entirely + - None: has a coding pragma, but it does not match + """ + __slots__ = () - # Ok case: the file is empty - if not (first_line + second_line + old).strip(): - return 0 + @property + def has_any_pragma(self): + return self.pragma_status is not False - # Ok case: we specify pragma as the first line - if first_line == expected_pragma: - return 0 + def is_expected_pragma(self, remove): + expected_pragma_status = not remove + return self.pragma_status is expected_pragma_status - # OK case: we have a shebang as first line and pragma on second line - if first_line.startswith(b'#!') and second_line == expected_pragma: - return 0 - # Otherwise we need to rewrite stuff! +def _get_expected_contents(first_line, second_line, rest): if first_line.startswith(b'#!'): - if has_coding(second_line): - f.write(first_line + expected_pragma + old) - else: - f.write(first_line + expected_pragma + second_line + old) - elif has_coding(first_line): - f.write(expected_pragma + second_line + old) + shebang = first_line + potential_coding = second_line else: - f.write(expected_pragma + first_line + second_line + old) + shebang = b'' + potential_coding = first_line + rest = second_line + rest + + if potential_coding == expected_pragma: + pragma_status = True + elif has_coding(potential_coding): + pragma_status = None + else: + pragma_status = False + rest = potential_coding + rest + + return ExpectedContents( + shebang=shebang, rest=rest, pragma_status=pragma_status, + ) + + +def fix_encoding_pragma(f, remove=False): + expected = _get_expected_contents(f.readline(), f.readline(), f.read()) + + # Special cases for empty files + if not expected.rest.strip(): + # If a file only has a shebang or a coding pragma, remove it + if expected.has_any_pragma or expected.shebang: + f.seek(0) + f.truncate() + f.write(b'') + return 1 + else: + return 0 + + if expected.is_expected_pragma(remove): + return 0 + + # Otherwise, write out the new file + f.seek(0) + f.truncate() + f.write(expected.shebang) + if not remove: + f.write(expected_pragma) + f.write(expected.rest) return 1 @@ -56,18 +94,25 @@ def fix_encoding_pragma(f): def main(argv=None): parser = argparse.ArgumentParser('Fixes the encoding pragma of python files') parser.add_argument('filenames', nargs='*', help='Filenames to fix') + parser.add_argument( + '--remove', action='store_true', + help='Remove the encoding pragma (Useful in a python3-only codebase)', + ) args = parser.parse_args(argv) retv = 0 + if args.remove: + fmt = 'Removed encoding pragma from {filename}' + else: + fmt = 'Added `{pragma}` to {filename}' + for filename in args.filenames: - with io.open(filename, 'r+b') as f: - file_ret = fix_encoding_pragma(f) + with open(filename, 'r+b') as f: + file_ret = fix_encoding_pragma(f, remove=args.remove) retv |= file_ret if file_ret: - print('Added `{0}` to {1}'.format( - expected_pragma.strip(), filename, - )) + print(fmt.format(pragma=expected_pragma, filename=filename)) return retv
pre-commit/pre-commit-hooks
17478a0a50faf20fd8e5b3fefe7435cea410df0b
diff --git a/tests/fix_encoding_pragma_test.py b/tests/fix_encoding_pragma_test.py index e000a33..a9502a2 100644 --- a/tests/fix_encoding_pragma_test.py +++ b/tests/fix_encoding_pragma_test.py @@ -10,32 +10,46 @@ from pre_commit_hooks.fix_encoding_pragma import main def test_integration_inserting_pragma(tmpdir): - file_path = tmpdir.join('foo.py').strpath + path = tmpdir.join('foo.py') + path.write_binary(b'import httplib\n') - with open(file_path, 'wb') as file_obj: - file_obj.write(b'import httplib\n') + assert main((path.strpath,)) == 1 - assert main([file_path]) == 1 - - with open(file_path, 'rb') as file_obj: - assert file_obj.read() == ( - b'# -*- coding: utf-8 -*-\n' - b'import httplib\n' - ) + assert path.read_binary() == ( + b'# -*- coding: utf-8 -*-\n' + b'import httplib\n' + ) def test_integration_ok(tmpdir): - file_path = tmpdir.join('foo.py').strpath - with open(file_path, 'wb') as file_obj: - file_obj.write(b'# -*- coding: utf-8 -*-\nx = 1\n') - assert main([file_path]) == 0 + path = tmpdir.join('foo.py') + path.write_binary(b'# -*- coding: utf-8 -*-\nx = 1\n') + assert main((path.strpath,)) == 0 + + +def test_integration_remove(tmpdir): + path = tmpdir.join('foo.py') + path.write_binary(b'# -*- coding: utf-8 -*-\nx = 1\n') + + assert main((path.strpath, '--remove')) == 1 + + assert path.read_binary() == b'x = 1\n' + + +def test_integration_remove_ok(tmpdir): + path = tmpdir.join('foo.py') + path.write_binary(b'x = 1\n') + assert main((path.strpath, '--remove')) == 0 @pytest.mark.parametrize( 'input_str', ( b'', - b'# -*- coding: utf-8 -*-\n', + ( + b'# -*- coding: utf-8 -*-\n' + b'x = 1\n' + ), ( b'#!/usr/bin/env python\n' b'# -*- coding: utf-8 -*-\n' @@ -59,20 +73,32 @@ def test_ok_inputs(input_str): b'import httplib\n', ), ( - b'#!/usr/bin/env python\n', + b'#!/usr/bin/env python\n' + b'x = 1\n', b'#!/usr/bin/env python\n' b'# -*- coding: utf-8 -*-\n' + b'x = 1\n', ), ( - b'#coding=utf-8\n', + b'#coding=utf-8\n' + b'x = 1\n', b'# -*- coding: utf-8 -*-\n' + b'x = 1\n', ), ( b'#!/usr/bin/env python\n' - b'#coding=utf8\n', + b'#coding=utf8\n' + b'x = 1\n', b'#!/usr/bin/env python\n' - b'# -*- coding: utf-8 -*-\n', + b'# -*- coding: utf-8 -*-\n' + b'x = 1\n', ), + # These should each get truncated + (b'#coding: utf-8\n', b''), + (b'# -*- coding: utf-8 -*-\n', b''), + (b'#!/usr/bin/env python\n', b''), + (b'#!/usr/bin/env python\n#coding: utf8\n', b''), + (b'#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n', b''), ) ) def test_not_ok_inputs(input_str, output):
Add a --remove option to fix-encoding-pragma This is an unnecessary thing in python3
0.0
17478a0a50faf20fd8e5b3fefe7435cea410df0b
[ "tests/fix_encoding_pragma_test.py::test_integration_remove", "tests/fix_encoding_pragma_test.py::test_integration_remove_ok", "tests/fix_encoding_pragma_test.py::test_not_ok_inputs[#!/usr/bin/env", "tests/fix_encoding_pragma_test.py::test_not_ok_inputs[#coding:", "tests/fix_encoding_pragma_test.py::test_not_ok_inputs[#" ]
[ "tests/fix_encoding_pragma_test.py::test_integration_inserting_pragma", "tests/fix_encoding_pragma_test.py::test_integration_ok", "tests/fix_encoding_pragma_test.py::test_ok_inputs[]", "tests/fix_encoding_pragma_test.py::test_ok_inputs[#", "tests/fix_encoding_pragma_test.py::test_ok_inputs[#!/usr/bin/env", "tests/fix_encoding_pragma_test.py::test_not_ok_inputs[import", "tests/fix_encoding_pragma_test.py::test_not_ok_inputs[#coding=utf-8\\nx" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2016-04-27 18:19:24+00:00
mit
4,658
pre-commit__pre-commit-hooks-135
diff --git a/pre_commit_hooks/trailing_whitespace_fixer.py b/pre_commit_hooks/trailing_whitespace_fixer.py index c159071..fa9b7dd 100644 --- a/pre_commit_hooks/trailing_whitespace_fixer.py +++ b/pre_commit_hooks/trailing_whitespace_fixer.py @@ -1,24 +1,27 @@ from __future__ import print_function import argparse -import fileinput import os import sys from pre_commit_hooks.util import cmd_output -def _fix_file(filename, markdown=False): - for line in fileinput.input([filename], inplace=True): - # preserve trailing two-space for non-blank lines in markdown files - if markdown and (not line.isspace()) and (line.endswith(" \n")): - line = line.rstrip(' \n') - # only preserve if there are no trailing tabs or unusual whitespace - if not line[-1].isspace(): - print(line + " ") - continue +def _fix_file(filename, is_markdown): + with open(filename, mode='rb') as file_processed: + lines = file_processed.readlines() + lines = [_process_line(line, is_markdown) for line in lines] + with open(filename, mode='wb') as file_processed: + for line in lines: + file_processed.write(line) - print(line.rstrip()) + +def _process_line(line, is_markdown): + # preserve trailing two-space for non-blank lines in markdown files + eol = b'\r\n' if line[-2:] == b'\r\n' else b'\n' + if is_markdown and (not line.isspace()) and line.endswith(b' ' + eol): + return line.rstrip() + b' ' + eol + return line.rstrip() + eol def fix_trailing_whitespace(argv=None): @@ -64,14 +67,13 @@ def fix_trailing_whitespace(argv=None): .format(ext) ) - if bad_whitespace_files: - for bad_whitespace_file in bad_whitespace_files: - print('Fixing {0}'.format(bad_whitespace_file)) - _, extension = os.path.splitext(bad_whitespace_file.lower()) - _fix_file(bad_whitespace_file, all_markdown or extension in md_exts) - return 1 - else: - return 0 + return_code = 0 + for bad_whitespace_file in bad_whitespace_files: + print('Fixing {0}'.format(bad_whitespace_file)) + _, extension = os.path.splitext(bad_whitespace_file.lower()) + _fix_file(bad_whitespace_file, all_markdown or extension in md_exts) + return_code = 1 + return return_code if __name__ == '__main__':
pre-commit/pre-commit-hooks
09d1747840bfb1457e9b8876b4c1f577d00a2a37
diff --git a/tests/trailing_whitespace_fixer_test.py b/tests/trailing_whitespace_fixer_test.py index 6f4fdfd..3a72ccb 100644 --- a/tests/trailing_whitespace_fixer_test.py +++ b/tests/trailing_whitespace_fixer_test.py @@ -42,7 +42,7 @@ def test_fixes_trailing_markdown_whitespace(filename, input_s, output, tmpdir): MD_TESTS_2 = ( ('foo.txt', 'foo \nbar \n \n', 'foo \nbar\n\n'), ('bar.Markdown', 'bar \nbaz\t\n\t\n', 'bar \nbaz\n\n'), - ('bar.MD', 'bar \nbaz\t \n\t\n', 'bar \nbaz\n\n'), + ('bar.MD', 'bar \nbaz\t \n\t\n', 'bar \nbaz \n\n'), ('.txt', 'baz \nquux \t\n\t\n', 'baz\nquux\n\n'), ('txt', 'foo \nbaz \n\t\n', 'foo\nbaz\n\n'), ) @@ -103,3 +103,12 @@ def test_no_markdown_linebreak_ext_opt(filename, input_s, output, tmpdir): def test_returns_zero_for_no_changes(): assert fix_trailing_whitespace([__file__]) == 0 + + +def test_preserve_non_utf8_file(tmpdir): + non_utf8_bytes_content = b'<a>\xe9 \n</a>\n' + path = tmpdir.join('file.txt') + path.write_binary(non_utf8_bytes_content) + ret = fix_trailing_whitespace([path.strpath]) + assert ret == 1 + assert path.size() == (len(non_utf8_bytes_content) - 1)
Non-utf8 file will cause trailing-whitespace to truncate the file contents Hi, (I started investigating this in https://github.com/pre-commit/pre-commit/issues/397) Bug reproductions steps, after setting up a git repository with the "trailing-whitespace" pre-commit hook installed (with the latest sha: 775a7906cd6004bec2401a85ed16d5b3540d2f94): ``` echo -en '\x3c\x61\x3e\xe9\x20\x0a\x3c\x2f\x61\x3e' > minimal_crasher.xml git add minimal_crasher.xml pre-commit run trailing-whitespace --files minimal_crasher.xml ``` Results in: ```` Trim Trailing Whitespace...............................................................................................................................................................Failed hookid: trailing-whitespace Files were modified by this hook. Additional output: Fixing minimal_crasher.xml Traceback (most recent call last): File "/home/lucas_cimon/.pre-commit/repok3wjweh4/py_env-default/bin/trailing-whitespace-fixer", line 9, in <module> load_entry_point('pre-commit-hooks==0.6.0', 'console_scripts', 'trailing-whitespace-fixer')() File "/home/lucas_cimon/.pre-commit/repok3wjweh4/py_env-default/lib/python3.4/site-packages/pre_commit_hooks/trailing_whitespace_fixer.py", line 71, in fix_trailing_whitespace _fix_file(bad_whitespace_file, all_markdown or extension in md_exts) File "/home/lucas_cimon/.pre-commit/repok3wjweh4/py_env-default/lib/python3.4/site-packages/pre_commit_hooks/trailing_whitespace_fixer.py", line 12, in _fix_file for line in fileinput.input([filename], inplace=True): File "/usr/lib/python3.4/fileinput.py", line 263, in __next__ line = self.readline() File "/usr/lib/python3.4/fileinput.py", line 363, in readline self._buffer = self._file.readlines(self._bufsize) File "/home/lucas_cimon/.pre-commit/repok3wjweh4/py_env-default/lib/python3.4/codecs.py", line 319, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 3: invalid continuation byte ``` And **all the content of `minimal_crasher.xml` lost** !! In this test the xml file is very small, but it can happen with any file size nor number of staged modifications !
0.0
09d1747840bfb1457e9b8876b4c1f577d00a2a37
[ "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[bar.MD-bar", "tests/trailing_whitespace_fixer_test.py::test_preserve_non_utf8_file" ]
[ "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_whitespace[foo", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_whitespace[bar\\t\\nbaz\\t\\n-bar\\nbaz\\n]", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[foo.md-foo", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[bar.Markdown-bar", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[.md-baz", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[txt-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[foo.txt-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[bar.Markdown-bar", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[.txt-baz", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[txt-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt_all[foo.baz-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt_all[bar-bar", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[--]", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[a.b]", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[a/b]", "tests/trailing_whitespace_fixer_test.py::test_no_markdown_linebreak_ext_opt[bar.md-bar", "tests/trailing_whitespace_fixer_test.py::test_no_markdown_linebreak_ext_opt[bar.markdown-baz", "tests/trailing_whitespace_fixer_test.py::test_returns_zero_for_no_changes" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_git_commit_hash" ], "has_test_patch": true, "is_lite": false }
2016-08-18 14:46:54+00:00
mit
4,659
pre-commit__pre-commit-hooks-172
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f261e54..a3bb7a4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ - repo: https://github.com/pre-commit/pre-commit-hooks - sha: 9ba5af45ce2d29b64c9a348a6fcff5553eea1f2c + sha: v0.7.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -13,12 +13,12 @@ - id: requirements-txt-fixer - id: flake8 - repo: https://github.com/pre-commit/pre-commit - sha: 8dba3281d5051060755459dcf88e28fc26c27526 + sha: v0.12.2 hooks: - id: validate_config - id: validate_manifest - repo: https://github.com/asottile/reorder_python_imports - sha: 3d86483455ab5bd06cc1069fdd5ac57be5463f10 + sha: v0.3.1 hooks: - id: reorder-python-imports language_version: python2.7 diff --git a/pre_commit_hooks/trailing_whitespace_fixer.py b/pre_commit_hooks/trailing_whitespace_fixer.py index fa9b7dd..d23d58d 100644 --- a/pre_commit_hooks/trailing_whitespace_fixer.py +++ b/pre_commit_hooks/trailing_whitespace_fixer.py @@ -10,10 +10,14 @@ from pre_commit_hooks.util import cmd_output def _fix_file(filename, is_markdown): with open(filename, mode='rb') as file_processed: lines = file_processed.readlines() - lines = [_process_line(line, is_markdown) for line in lines] - with open(filename, mode='wb') as file_processed: - for line in lines: - file_processed.write(line) + newlines = [_process_line(line, is_markdown) for line in lines] + if newlines != lines: + with open(filename, mode='wb') as file_processed: + for line in newlines: + file_processed.write(line) + return True + else: + return False def _process_line(line, is_markdown): @@ -55,8 +59,9 @@ def fix_trailing_whitespace(argv=None): parser.error('--markdown-linebreak-ext requires a non-empty argument') all_markdown = '*' in md_args # normalize all extensions; split at ',', lowercase, and force 1 leading '.' - md_exts = ['.' + x.lower().lstrip('.') - for x in ','.join(md_args).split(',')] + md_exts = [ + '.' + x.lower().lstrip('.') for x in ','.join(md_args).split(',') + ] # reject probable "eaten" filename as extension (skip leading '.' with [1:]) for ext in md_exts: @@ -69,10 +74,11 @@ def fix_trailing_whitespace(argv=None): return_code = 0 for bad_whitespace_file in bad_whitespace_files: - print('Fixing {0}'.format(bad_whitespace_file)) _, extension = os.path.splitext(bad_whitespace_file.lower()) - _fix_file(bad_whitespace_file, all_markdown or extension in md_exts) - return_code = 1 + md = all_markdown or extension in md_exts + if _fix_file(bad_whitespace_file, md): + print('Fixing {}'.format(bad_whitespace_file)) + return_code = 1 return return_code
pre-commit/pre-commit-hooks
46251c9523506b68419aefdf5ff6ff2fbc4506a4
diff --git a/tests/trailing_whitespace_fixer_test.py b/tests/trailing_whitespace_fixer_test.py index 3a72ccb..eb2a1d0 100644 --- a/tests/trailing_whitespace_fixer_test.py +++ b/tests/trailing_whitespace_fixer_test.py @@ -20,6 +20,22 @@ def test_fixes_trailing_whitespace(input_s, expected, tmpdir): assert path.read() == expected +def test_ok_with_dos_line_endings(tmpdir): + filename = tmpdir.join('f') + filename.write_binary(b'foo\r\nbar\r\nbaz\r\n') + ret = fix_trailing_whitespace((filename.strpath,)) + assert filename.read_binary() == b'foo\r\nbar\r\nbaz\r\n' + assert ret == 0 + + +def test_markdown_ok(tmpdir): + filename = tmpdir.join('foo.md') + filename.write_binary(b'foo \n') + ret = fix_trailing_whitespace((filename.strpath,)) + assert filename.read_binary() == b'foo \n' + assert ret == 0 + + # filename, expected input, expected output MD_TESTS_1 = ( ('foo.md', 'foo \nbar \n ', 'foo \nbar\n\n'),
DOS ending files fail, claim they are rewritten, but don't change file contents (trailing-whitespace-fixer)
0.0
46251c9523506b68419aefdf5ff6ff2fbc4506a4
[ "tests/trailing_whitespace_fixer_test.py::test_ok_with_dos_line_endings", "tests/trailing_whitespace_fixer_test.py::test_markdown_ok" ]
[ "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_whitespace[foo", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_whitespace[bar\\t\\nbaz\\t\\n-bar\\nbaz\\n]", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[foo.md-foo", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[bar.Markdown-bar", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[.md-baz", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[txt-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[foo.txt-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[bar.Markdown-bar", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[bar.MD-bar", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[.txt-baz", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[txt-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt_all[foo.baz-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt_all[bar-bar", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[--]", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[a.b]", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[a/b]", "tests/trailing_whitespace_fixer_test.py::test_no_markdown_linebreak_ext_opt[bar.md-bar", "tests/trailing_whitespace_fixer_test.py::test_no_markdown_linebreak_ext_opt[bar.markdown-baz", "tests/trailing_whitespace_fixer_test.py::test_returns_zero_for_no_changes", "tests/trailing_whitespace_fixer_test.py::test_preserve_non_utf8_file" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2017-02-07 17:38:17+00:00
mit
4,660
pre-commit__pre-commit-hooks-205
diff --git a/.gitignore b/.gitignore index 2626934..6fdf044 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.iml *.py[co] .*.sw[a-z] +.cache .coverage .idea .project diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index bda3f76..e7f433b 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -147,6 +147,12 @@ entry: requirements-txt-fixer language: python files: requirements.*\.txt$ +- id: sort-simple-yaml + name: Sort simple YAML files + language: python + entry: sort-simple-yaml + description: Sorts simple YAML files which consist only of top-level keys, preserving comments and blocks. + files: '^$' - id: trailing-whitespace name: Trim Trailing Whitespace description: This hook trims trailing whitespace. diff --git a/README.md b/README.md index 3b62234..8db7eef 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Add this to your `.pre-commit-config.yaml` - `--no-sort-keys` - when autofixing, retain the original key ordering (instead of sorting the keys) - `--top-keys comma,separated,keys` - Keys to keep at the top of mappings. - `requirements-txt-fixer` - Sorts entries in requirements.txt +- `sort-simple-yaml` - Sorts simple YAML files which consist only of top-level keys, preserving comments and blocks. - `trailing-whitespace` - Trims trailing whitespace. - Markdown linebreak trailing spaces preserved for `.md` and`.markdown`; use `args: ['--markdown-linebreak-ext=txt,text']` to add other extensions, diff --git a/hooks.yaml b/hooks.yaml index bda3f76..e7f433b 100644 --- a/hooks.yaml +++ b/hooks.yaml @@ -147,6 +147,12 @@ entry: requirements-txt-fixer language: python files: requirements.*\.txt$ +- id: sort-simple-yaml + name: Sort simple YAML files + language: python + entry: sort-simple-yaml + description: Sorts simple YAML files which consist only of top-level keys, preserving comments and blocks. + files: '^$' - id: trailing-whitespace name: Trim Trailing Whitespace description: This hook trims trailing whitespace. diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py index efa1906..41e1ffc 100644 --- a/pre_commit_hooks/requirements_txt_fixer.py +++ b/pre_commit_hooks/requirements_txt_fixer.py @@ -30,21 +30,25 @@ class Requirement(object): def fix_requirements(f): requirements = [] - before = [] + before = list(f) after = [] - for line in f: - before.append(line) + before_string = b''.join(before) + + # If the file is empty (i.e. only whitespace/newlines) exit early + if before_string.strip() == b'': + return 0 - # If the most recent requirement object has a value, then it's time to - # start building the next requirement object. + for line in before: + # If the most recent requirement object has a value, then it's + # time to start building the next requirement object. if not len(requirements) or requirements[-1].value is not None: requirements.append(Requirement()) requirement = requirements[-1] - # If we see a newline before any requirements, then this is a top of - # file comment. + # If we see a newline before any requirements, then this is a + # top of file comment. if len(requirements) == 1 and line.strip() == b'': if len(requirement.comments) and requirement.comments[0].startswith(b'#'): requirement.value = b'\n' @@ -60,7 +64,6 @@ def fix_requirements(f): after.append(comment) after.append(requirement.value) - before_string = b''.join(before) after_string = b''.join(after) if before_string == after_string: diff --git a/pre_commit_hooks/sort_simple_yaml.py b/pre_commit_hooks/sort_simple_yaml.py new file mode 100755 index 0000000..7afae91 --- /dev/null +++ b/pre_commit_hooks/sort_simple_yaml.py @@ -0,0 +1,123 @@ +#!/usr/bin/env python +"""Sort a simple YAML file, keeping blocks of comments and definitions +together. + +We assume a strict subset of YAML that looks like: + + # block of header comments + # here that should always + # be at the top of the file + + # optional comments + # can go here + key: value + key: value + + key: value + +In other words, we don't sort deeper than the top layer, and might corrupt +complicated YAML files. +""" +from __future__ import print_function + +import argparse + + +QUOTES = ["'", '"'] + + +def sort(lines): + """Sort a YAML file in alphabetical order, keeping blocks together. + + :param lines: array of strings (without newlines) + :return: sorted array of strings + """ + # make a copy of lines since we will clobber it + lines = list(lines) + new_lines = parse_block(lines, header=True) + + for block in sorted(parse_blocks(lines), key=first_key): + if new_lines: + new_lines.append('') + new_lines.extend(block) + + return new_lines + + +def parse_block(lines, header=False): + """Parse and return a single block, popping off the start of `lines`. + + If parsing a header block, we stop after we reach a line that is not a + comment. Otherwise, we stop after reaching an empty line. + + :param lines: list of lines + :param header: whether we are parsing a header block + :return: list of lines that form the single block + """ + block_lines = [] + while lines and lines[0] and (not header or lines[0].startswith('#')): + block_lines.append(lines.pop(0)) + return block_lines + + +def parse_blocks(lines): + """Parse and return all possible blocks, popping off the start of `lines`. + + :param lines: list of lines + :return: list of blocks, where each block is a list of lines + """ + blocks = [] + + while lines: + if lines[0] == '': + lines.pop(0) + else: + blocks.append(parse_block(lines)) + + return blocks + + +def first_key(lines): + """Returns a string representing the sort key of a block. + + The sort key is the first YAML key we encounter, ignoring comments, and + stripping leading quotes. + + >>> print(test) + # some comment + 'foo': true + >>> first_key(test) + 'foo' + """ + for line in lines: + if line.startswith('#'): + continue + if any(line.startswith(quote) for quote in QUOTES): + return line[1:] + return line + + +def main(argv=None): + parser = argparse.ArgumentParser() + parser.add_argument('filenames', nargs='*', help='Filenames to fix') + args = parser.parse_args(argv) + + retval = 0 + + for filename in args.filenames: + with open(filename, 'r+') as f: + lines = [line.rstrip() for line in f.readlines()] + new_lines = sort(lines) + + if lines != new_lines: + print("Fixing file `{filename}`".format(filename=filename)) + f.seek(0) + f.write("\n".join(new_lines) + "\n") + f.truncate() + retval = 1 + + return retval + + +if __name__ == '__main__': + exit(main()) diff --git a/setup.py b/setup.py index 4abb7a2..af21e16 100644 --- a/setup.py +++ b/setup.py @@ -55,6 +55,7 @@ setup( 'no-commit-to-branch = pre_commit_hooks.no_commit_to_branch:main', 'pretty-format-json = pre_commit_hooks.pretty_format_json:pretty_format_json', 'requirements-txt-fixer = pre_commit_hooks.requirements_txt_fixer:fix_requirements_txt', + 'sort-simple-yaml = pre_commit_hooks.sort_simple_yaml:main', 'trailing-whitespace-fixer = pre_commit_hooks.trailing_whitespace_fixer:fix_trailing_whitespace', ], },
pre-commit/pre-commit-hooks
78818b90cd694c29333ba54d38f9e60b6359ccfc
diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py index 1c590a5..33f6a47 100644 --- a/tests/requirements_txt_fixer_test.py +++ b/tests/requirements_txt_fixer_test.py @@ -5,6 +5,8 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement # Input, expected return value, expected output TESTS = ( + (b'', 0, b''), + (b'\n', 0, b'\n'), (b'foo\nbar\n', 1, b'bar\nfoo\n'), (b'bar\nfoo\n', 0, b'bar\nfoo\n'), (b'#comment1\nfoo\n#comment2\nbar\n', 1, b'#comment2\nbar\n#comment1\nfoo\n'), diff --git a/tests/sort_simple_yaml_test.py b/tests/sort_simple_yaml_test.py new file mode 100644 index 0000000..176d12f --- /dev/null +++ b/tests/sort_simple_yaml_test.py @@ -0,0 +1,120 @@ +from __future__ import absolute_import +from __future__ import unicode_literals + +import os + +import pytest + +from pre_commit_hooks.sort_simple_yaml import first_key +from pre_commit_hooks.sort_simple_yaml import main +from pre_commit_hooks.sort_simple_yaml import parse_block +from pre_commit_hooks.sort_simple_yaml import parse_blocks +from pre_commit_hooks.sort_simple_yaml import sort + +RETVAL_GOOD = 0 +RETVAL_BAD = 1 +TEST_SORTS = [ + ( + ['c: true', '', 'b: 42', 'a: 19'], + ['b: 42', 'a: 19', '', 'c: true'], + RETVAL_BAD, + ), + + ( + ['# i am', '# a header', '', 'c: true', '', 'b: 42', 'a: 19'], + ['# i am', '# a header', '', 'b: 42', 'a: 19', '', 'c: true'], + RETVAL_BAD, + ), + + ( + ['# i am', '# a header', '', 'already: sorted', '', 'yup: i am'], + ['# i am', '# a header', '', 'already: sorted', '', 'yup: i am'], + RETVAL_GOOD, + ), + + ( + ['# i am', '# a header'], + ['# i am', '# a header'], + RETVAL_GOOD, + ), +] + + [email protected]('bad_lines,good_lines,retval', TEST_SORTS) +def test_integration_good_bad_lines(tmpdir, bad_lines, good_lines, retval): + file_path = os.path.join(tmpdir.strpath, 'foo.yaml') + + with open(file_path, 'w') as f: + f.write("\n".join(bad_lines) + "\n") + + assert main([file_path]) == retval + + with open(file_path, 'r') as f: + assert [line.rstrip() for line in f.readlines()] == good_lines + + +def test_parse_header(): + lines = ['# some header', '# is here', '', 'this is not a header'] + assert parse_block(lines, header=True) == ['# some header', '# is here'] + assert lines == ['', 'this is not a header'] + + lines = ['this is not a header'] + assert parse_block(lines, header=True) == [] + assert lines == ['this is not a header'] + + +def test_parse_block(): + # a normal block + lines = ['a: 42', 'b: 17', '', 'c: 19'] + assert parse_block(lines) == ['a: 42', 'b: 17'] + assert lines == ['', 'c: 19'] + + # a block at the end + lines = ['c: 19'] + assert parse_block(lines) == ['c: 19'] + assert lines == [] + + # no block + lines = [] + assert parse_block(lines) == [] + assert lines == [] + + +def test_parse_blocks(): + # normal blocks + lines = ['a: 42', 'b: 17', '', 'c: 19'] + assert parse_blocks(lines) == [['a: 42', 'b: 17'], ['c: 19']] + assert lines == [] + + # a single block + lines = ['a: 42', 'b: 17'] + assert parse_blocks(lines) == [['a: 42', 'b: 17']] + assert lines == [] + + # no blocks + lines = [] + assert parse_blocks(lines) == [] + assert lines == [] + + +def test_first_key(): + # first line + lines = ['a: 42', 'b: 17', '', 'c: 19'] + assert first_key(lines) == 'a: 42' + + # second line + lines = ['# some comment', 'a: 42', 'b: 17', '', 'c: 19'] + assert first_key(lines) == 'a: 42' + + # second line with quotes + lines = ['# some comment', '"a": 42', 'b: 17', '', 'c: 19'] + assert first_key(lines) == 'a": 42' + + # no lines + lines = [] + assert first_key(lines) is None + + [email protected]('bad_lines,good_lines,_', TEST_SORTS) +def test_sort(bad_lines, good_lines, _): + assert sort(bad_lines) == good_lines
requirements-txt-fixer broken for empty requirements.txt A bit of an edge case, shouldn't crash though: ```python Sorting requirements.txt Traceback (most recent call last): File "/nail/tmp/tmp25dodv0q/venv/bin/requirements-txt-fixer", line 11, in <module> sys.exit(fix_requirements_txt()) File "/nail/tmp/tmp25dodv0q/venv/lib/python3.5/site-packages/pre_commit_hooks/requirements_txt_fixer.py", line 84, in fix_requirements_txt ret_for_file = fix_requirements(file_obj) File "/nail/tmp/tmp25dodv0q/venv/lib/python3.5/site-packages/pre_commit_hooks/requirements_txt_fixer.py", line 64, in fix_requirements after_string = b''.join(after) TypeError: sequence item 1: expected a bytes-like object, NoneType found ```
0.0
78818b90cd694c29333ba54d38f9e60b6359ccfc
[ "tests/requirements_txt_fixer_test.py::test_integration[-0-]", "tests/requirements_txt_fixer_test.py::test_integration[\\n-0-\\n]", "tests/requirements_txt_fixer_test.py::test_integration[foo\\nbar\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[bar\\nfoo\\n-0-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment1\\nfoo\\n#comment2\\nbar\\n-1-#comment2\\nbar\\n#comment1\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment1\\nbar\\n#comment2\\nfoo\\n-0-#comment1\\nbar\\n#comment2\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment\\n\\nfoo\\nbar\\n-1-#comment\\n\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment\\n\\nbar\\nfoo\\n-0-#comment\\n\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[\\nfoo\\nbar\\n-1-bar\\n\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[\\nbar\\nfoo\\n-0-\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[pyramid==1\\npyramid-foo==2\\n-0-pyramid==1\\npyramid-foo==2\\n]", "tests/requirements_txt_fixer_test.py::test_integration[ocflib\\nDjango\\nPyMySQL\\n-1-Django\\nocflib\\nPyMySQL\\n]", "tests/requirements_txt_fixer_test.py::test_integration[-e", "tests/requirements_txt_fixer_test.py::test_requirement_object", "tests/sort_simple_yaml_test.py::test_integration_good_bad_lines[bad_lines0-good_lines0-1]", "tests/sort_simple_yaml_test.py::test_integration_good_bad_lines[bad_lines1-good_lines1-1]", "tests/sort_simple_yaml_test.py::test_integration_good_bad_lines[bad_lines2-good_lines2-0]", "tests/sort_simple_yaml_test.py::test_integration_good_bad_lines[bad_lines3-good_lines3-0]", "tests/sort_simple_yaml_test.py::test_parse_header", "tests/sort_simple_yaml_test.py::test_parse_block", "tests/sort_simple_yaml_test.py::test_parse_blocks", "tests/sort_simple_yaml_test.py::test_first_key", "tests/sort_simple_yaml_test.py::test_sort[bad_lines0-good_lines0-1]", "tests/sort_simple_yaml_test.py::test_sort[bad_lines1-good_lines1-1]", "tests/sort_simple_yaml_test.py::test_sort[bad_lines2-good_lines2-0]", "tests/sort_simple_yaml_test.py::test_sort[bad_lines3-good_lines3-0]" ]
[]
{ "failed_lite_validators": [ "has_added_files", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2017-06-24 00:21:06+00:00
mit
4,661
pre-commit__pre-commit-hooks-240
diff --git a/pre_commit_hooks/mixed_line_ending.py b/pre_commit_hooks/mixed_line_ending.py index 301c654..a163726 100644 --- a/pre_commit_hooks/mixed_line_ending.py +++ b/pre_commit_hooks/mixed_line_ending.py @@ -55,7 +55,8 @@ def fix_filename(filename, fix): else: target_ending = FIX_TO_LINE_ENDING[fix] # find if there are lines with *other* endings - del counts[target_ending] + # It's possible there's no line endings of the target type + counts.pop(target_ending, None) other_endings = bool(sum(counts.values())) if other_endings: _fix(filename, contents, target_ending)
pre-commit/pre-commit-hooks
efdceb4e40cda10780f4646ec944f55b5786190d
diff --git a/tests/mixed_line_ending_test.py b/tests/mixed_line_ending_test.py index 808295b..23837cd 100644 --- a/tests/mixed_line_ending_test.py +++ b/tests/mixed_line_ending_test.py @@ -101,3 +101,13 @@ def test_fix_crlf(tmpdir): assert ret == 1 assert path.read_binary() == b'foo\r\nbar\r\nbaz\r\n' + + +def test_fix_lf_all_crlf(tmpdir): + """Regression test for #239""" + path = tmpdir.join('input.txt') + path.write_binary(b'foo\r\nbar\r\n') + ret = main(('--fix=lf', path.strpath)) + + assert ret == 1 + assert path.read_binary() == b'foo\nbar\n'
mixed-line-ending -- KeyError: b'\n' `pre-commit 1.1.2` ```bash Mixed line ending........................................................Failed hookid: mixed-line-ending Traceback (most recent call last): File "/home/gary/.cache/pre-commit/repos71slzol/py_env-python3.6/bin/mixed-line-ending", line 11, in <module> load_entry_point('pre-commit-hooks==0.9.4', 'console_scripts', 'mixed-line-ending')() File "/home/gary/.cache/pre-commit/repos71slzol/py_env-python3.6/lib/python3.6/site-packages/pre_commit_hooks/mixed_line_ending.py", line 78, in main retv |= fix_filename(filename, args.fix) File "/home/gary/.cache/pre-commit/repos71slzol/py_env-python3.6/lib/python3.6/site-packages/pre_commit_hooks/mixed_line_ending.py", line 58, in fix_filename del counts[target_ending] KeyError: b'\n' ``` ```yaml - repo: git://github.com/pre-commit/pre-commit-hooks sha: v0.9.4 hooks: - id: mixed-line-ending args: [--fix=lf] ```
0.0
efdceb4e40cda10780f4646ec944f55b5786190d
[ "tests/mixed_line_ending_test.py::test_fix_lf_all_crlf" ]
[ "tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\\r\\nbar\\nbaz\\n-foo\\nbar\\nbaz\\n]", "tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\\r\\nbar\\nbaz\\r\\n-foo\\r\\nbar\\r\\nbaz\\r\\n]", "tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\\rbar\\nbaz\\r-foo\\rbar\\rbaz\\r]", "tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\\r\\nbar\\n-foo\\nbar\\n]", "tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\\rbar\\n-foo\\nbar\\n]", "tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\\r\\nbar\\r-foo\\r\\nbar\\r\\n]", "tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\\r\\nbar\\nbaz\\r-foo\\nbar\\nbaz\\n]", "tests/mixed_line_ending_test.py::test_non_mixed_no_newline_end_of_file", "tests/mixed_line_ending_test.py::test_mixed_no_newline_end_of_file", "tests/mixed_line_ending_test.py::test_line_endings_ok[--fix=auto-foo\\r\\nbar\\r\\nbaz\\r\\n]", "tests/mixed_line_ending_test.py::test_line_endings_ok[--fix=auto-foo\\rbar\\rbaz\\r]", "tests/mixed_line_ending_test.py::test_line_endings_ok[--fix=auto-foo\\nbar\\nbaz\\n]", "tests/mixed_line_ending_test.py::test_line_endings_ok[--fix=crlf-foo\\r\\nbar\\r\\nbaz\\r\\n]", "tests/mixed_line_ending_test.py::test_line_endings_ok[--fix=lf-foo\\nbar\\nbaz\\n]", "tests/mixed_line_ending_test.py::test_no_fix_does_not_modify", "tests/mixed_line_ending_test.py::test_fix_lf", "tests/mixed_line_ending_test.py::test_fix_crlf" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2017-09-27 14:48:20+00:00
mit
4,662
pre-commit__pre-commit-hooks-271
diff --git a/pre_commit_hooks/trailing_whitespace_fixer.py b/pre_commit_hooks/trailing_whitespace_fixer.py index 26f7b51..062f6e3 100644 --- a/pre_commit_hooks/trailing_whitespace_fixer.py +++ b/pre_commit_hooks/trailing_whitespace_fixer.py @@ -19,14 +19,19 @@ def _fix_file(filename, is_markdown): def _process_line(line, is_markdown): + if line[-2:] == b'\r\n': + eol = b'\r\n' + elif line[-1:] == b'\n': + eol = b'\n' + else: + eol = b'' # preserve trailing two-space for non-blank lines in markdown files - eol = b'\r\n' if line[-2:] == b'\r\n' else b'\n' if is_markdown and (not line.isspace()) and line.endswith(b' ' + eol): return line.rstrip() + b' ' + eol return line.rstrip() + eol -def fix_trailing_whitespace(argv=None): +def main(argv=None): parser = argparse.ArgumentParser() parser.add_argument( '--no-markdown-linebreak-ext', @@ -77,4 +82,4 @@ def fix_trailing_whitespace(argv=None): if __name__ == '__main__': - sys.exit(fix_trailing_whitespace()) + sys.exit(main())
pre-commit/pre-commit-hooks
2f8b625855c86eece2219fe6910285611c7a4271
diff --git a/tests/trailing_whitespace_fixer_test.py b/tests/trailing_whitespace_fixer_test.py index a771e67..7ee9e63 100644 --- a/tests/trailing_whitespace_fixer_test.py +++ b/tests/trailing_whitespace_fixer_test.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import pytest -from pre_commit_hooks.trailing_whitespace_fixer import fix_trailing_whitespace +from pre_commit_hooks.trailing_whitespace_fixer import main @pytest.mark.parametrize( @@ -16,14 +16,22 @@ from pre_commit_hooks.trailing_whitespace_fixer import fix_trailing_whitespace def test_fixes_trailing_whitespace(input_s, expected, tmpdir): path = tmpdir.join('file.txt') path.write(input_s) - assert fix_trailing_whitespace((path.strpath,)) == 1 + assert main((path.strpath,)) == 1 assert path.read() == expected +def test_ok_no_newline_end_of_file(tmpdir): + filename = tmpdir.join('f') + filename.write_binary(b'foo\nbar') + ret = main((filename.strpath,)) + assert filename.read_binary() == b'foo\nbar' + assert ret == 0 + + def test_ok_with_dos_line_endings(tmpdir): filename = tmpdir.join('f') filename.write_binary(b'foo\r\nbar\r\nbaz\r\n') - ret = fix_trailing_whitespace((filename.strpath,)) + ret = main((filename.strpath,)) assert filename.read_binary() == b'foo\r\nbar\r\nbaz\r\n' assert ret == 0 @@ -31,14 +39,14 @@ def test_ok_with_dos_line_endings(tmpdir): def test_markdown_ok(tmpdir): filename = tmpdir.join('foo.md') filename.write_binary(b'foo \n') - ret = fix_trailing_whitespace((filename.strpath,)) + ret = main((filename.strpath,)) assert filename.read_binary() == b'foo \n' assert ret == 0 # filename, expected input, expected output MD_TESTS_1 = ( - ('foo.md', 'foo \nbar \n ', 'foo \nbar\n\n'), + ('foo.md', 'foo \nbar \n ', 'foo \nbar\n'), ('bar.Markdown', 'bar \nbaz\t\n\t\n', 'bar \nbaz\n\n'), ('.md', 'baz \nquux \t\n\t\n', 'baz\nquux\n\n'), ('txt', 'foo \nbaz \n\t\n', 'foo\nbaz\n\n'), @@ -49,7 +57,7 @@ MD_TESTS_1 = ( def test_fixes_trailing_markdown_whitespace(filename, input_s, output, tmpdir): path = tmpdir.join(filename) path.write(input_s) - ret = fix_trailing_whitespace([path.strpath]) + ret = main([path.strpath]) assert ret == 1 assert path.read() == output @@ -68,16 +76,14 @@ MD_TESTS_2 = ( def test_markdown_linebreak_ext_opt(filename, input_s, output, tmpdir): path = tmpdir.join(filename) path.write(input_s) - ret = fix_trailing_whitespace(( - '--markdown-linebreak-ext=TxT', path.strpath, - )) + ret = main(('--markdown-linebreak-ext=TxT', path.strpath)) assert ret == 1 assert path.read() == output # filename, expected input, expected output MD_TESTS_3 = ( - ('foo.baz', 'foo \nbar \n ', 'foo \nbar\n\n'), + ('foo.baz', 'foo \nbar \n ', 'foo \nbar\n'), ('bar', 'bar \nbaz\t\n\t\n', 'bar \nbaz\n\n'), ) @@ -87,9 +93,7 @@ def test_markdown_linebreak_ext_opt_all(filename, input_s, output, tmpdir): path = tmpdir.join(filename) path.write(input_s) # need to make sure filename is not treated as argument to option - ret = fix_trailing_whitespace([ - '--markdown-linebreak-ext=*', path.strpath, - ]) + ret = main(('--markdown-linebreak-ext=*', path.strpath)) assert ret == 1 assert path.read() == output @@ -97,7 +101,7 @@ def test_markdown_linebreak_ext_opt_all(filename, input_s, output, tmpdir): @pytest.mark.parametrize(('arg'), ('--', 'a.b', 'a/b')) def test_markdown_linebreak_ext_badopt(arg): with pytest.raises(SystemExit) as excinfo: - fix_trailing_whitespace(['--markdown-linebreak-ext', arg]) + main(['--markdown-linebreak-ext', arg]) assert excinfo.value.code == 2 @@ -112,19 +116,15 @@ MD_TESTS_4 = ( def test_no_markdown_linebreak_ext_opt(filename, input_s, output, tmpdir): path = tmpdir.join(filename) path.write(input_s) - ret = fix_trailing_whitespace(['--no-markdown-linebreak-ext', path.strpath]) + ret = main(['--no-markdown-linebreak-ext', path.strpath]) assert ret == 1 assert path.read() == output -def test_returns_zero_for_no_changes(): - assert fix_trailing_whitespace([__file__]) == 0 - - def test_preserve_non_utf8_file(tmpdir): non_utf8_bytes_content = b'<a>\xe9 \n</a>\n' path = tmpdir.join('file.txt') path.write_binary(non_utf8_bytes_content) - ret = fix_trailing_whitespace([path.strpath]) + ret = main([path.strpath]) assert ret == 1 assert path.size() == (len(non_utf8_bytes_content) - 1)
trailing-whitespace fixer getting false positive While bringing some Terraform files under pre-commit control, I've noticed an issue with files that do not have trailing whitespace but which are being flagged as needing fixing by the `trailing-whitespace` hook, which is causing a Travis CI build to fail unexpectedly. The files in question seem to trigger because they do not end in a newline, and I believe this to be incorrect behaviour for this hook. Example repo: https://github.com/digirati-co-uk/pre-commit-hooks-test This is using v1.2.1 of the pre-commit-hooks repo. ![pre-commit-hooks-test-screenshot](https://user-images.githubusercontent.com/657772/36797780-c2a0343a-1ca0-11e8-8ae3-2e3f4a53e8a0.PNG)
0.0
2f8b625855c86eece2219fe6910285611c7a4271
[ "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_whitespace[foo", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_whitespace[bar\\t\\nbaz\\t\\n-bar\\nbaz\\n]", "tests/trailing_whitespace_fixer_test.py::test_ok_no_newline_end_of_file", "tests/trailing_whitespace_fixer_test.py::test_ok_with_dos_line_endings", "tests/trailing_whitespace_fixer_test.py::test_markdown_ok", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[foo.md-foo", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[bar.Markdown-bar", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[.md-baz", "tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[txt-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[foo.txt-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[bar.Markdown-bar", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[bar.MD-bar", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[.txt-baz", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[txt-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt_all[foo.baz-foo", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt_all[bar-bar", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[--]", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[a.b]", "tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[a/b]", "tests/trailing_whitespace_fixer_test.py::test_no_markdown_linebreak_ext_opt[bar.md-bar", "tests/trailing_whitespace_fixer_test.py::test_no_markdown_linebreak_ext_opt[bar.markdown-baz", "tests/trailing_whitespace_fixer_test.py::test_preserve_non_utf8_file" ]
[]
{ "failed_lite_validators": [ "has_hyperlinks", "has_media" ], "has_test_patch": true, "is_lite": false }
2018-02-28 16:44:03+00:00
mit
4,663
pre-commit__pre-commit-hooks-274
diff --git a/README.md b/README.md index 8d21a68..41e9103 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,11 @@ Add this to your `.pre-commit-config.yaml` - `check-yaml` - Attempts to load all yaml files to verify syntax. - `--allow-multiple-documents` - allow yaml files which use the [multi-document syntax](http://www.yaml.org/spec/1.2/spec.html#YAML) + - `--unsafe` - Instaed of loading the files, simply parse them for syntax. + A syntax-only check enables extensions and unsafe constructs which would + otherwise be forbidden. Using this option removes all guarantees of + portability to other yaml implementations. + Implies `--allow-multiple-documents`. - `debug-statements` - Check for pdb / ipdb / pudb statements in code. - `detect-aws-credentials` - Checks for the existence of AWS secrets that you have set up with the AWS CLI. diff --git a/pre_commit_hooks/check_yaml.py b/pre_commit_hooks/check_yaml.py index e9bb8f0..9fbbd88 100644 --- a/pre_commit_hooks/check_yaml.py +++ b/pre_commit_hooks/check_yaml.py @@ -1,6 +1,7 @@ from __future__ import print_function import argparse +import collections import sys import yaml @@ -11,24 +12,52 @@ except ImportError: # pragma: no cover (no libyaml-dev / pypy) Loader = yaml.SafeLoader +def _exhaust(gen): + for _ in gen: + pass + + +def _parse_unsafe(*args, **kwargs): + _exhaust(yaml.parse(*args, **kwargs)) + + def _load_all(*args, **kwargs): - # need to exhaust the generator - return tuple(yaml.load_all(*args, **kwargs)) + _exhaust(yaml.load_all(*args, **kwargs)) + + +Key = collections.namedtuple('Key', ('multi', 'unsafe')) +LOAD_FNS = { + Key(multi=False, unsafe=False): yaml.load, + Key(multi=False, unsafe=True): _parse_unsafe, + Key(multi=True, unsafe=False): _load_all, + Key(multi=True, unsafe=True): _parse_unsafe, +} def check_yaml(argv=None): parser = argparse.ArgumentParser() parser.add_argument( - '-m', '--allow-multiple-documents', dest='yaml_load_fn', - action='store_const', const=_load_all, default=yaml.load, + '-m', '--multi', '--allow-multiple-documents', action='store_true', + ) + parser.add_argument( + '--unsafe', action='store_true', + help=( + 'Instead of loading the files, simply parse them for syntax. ' + 'A syntax-only check enables extensions and unsafe contstructs ' + 'which would otherwise be forbidden. Using this option removes ' + 'all guarantees of portability to other yaml implementations. ' + 'Implies --allow-multiple-documents' + ), ) parser.add_argument('filenames', nargs='*', help='Yaml filenames to check.') args = parser.parse_args(argv) + load_fn = LOAD_FNS[Key(multi=args.multi, unsafe=args.unsafe)] + retval = 0 for filename in args.filenames: try: - args.yaml_load_fn(open(filename), Loader=Loader) + load_fn(open(filename), Loader=Loader) except yaml.YAMLError as exc: print(exc) retval = 1
pre-commit/pre-commit-hooks
e80813e7e9bceeb263a4329341f2681074fa725a
diff --git a/tests/check_yaml_test.py b/tests/check_yaml_test.py index de3b383..aa357f1 100644 --- a/tests/check_yaml_test.py +++ b/tests/check_yaml_test.py @@ -22,7 +22,7 @@ def test_check_yaml_allow_multiple_documents(tmpdir): f = tmpdir.join('test.yaml') f.write('---\nfoo\n---\nbar\n') - # should failw without the setting + # should fail without the setting assert check_yaml((f.strpath,)) # should pass when we allow multiple documents @@ -33,3 +33,22 @@ def test_fails_even_with_allow_multiple_documents(tmpdir): f = tmpdir.join('test.yaml') f.write('[') assert check_yaml(('--allow-multiple-documents', f.strpath)) + + +def test_check_yaml_unsafe(tmpdir): + f = tmpdir.join('test.yaml') + f.write( + 'some_foo: !vault |\n' + ' $ANSIBLE_VAULT;1.1;AES256\n' + ' deadbeefdeadbeefdeadbeef\n', + ) + # should fail "safe" check + assert check_yaml((f.strpath,)) + # should pass when we allow unsafe documents + assert not check_yaml(('--unsafe', f.strpath)) + + +def test_check_yaml_unsafe_still_fails_on_syntax_errors(tmpdir): + f = tmpdir.join('test.yaml') + f.write('[') + assert check_yaml(('--unsafe', f.strpath))
Check-yaml exception for Ansible Vault Hi, I've recently used the [embed encrypt variables](https://docs.ansible.com/ansible/latest/vault.html#encrypt-string-for-use-in-yaml) in my Ansible repos, and the check-yaml hook is failing because of the specific `!vault` usage. ``` Check Yaml...............................................................Failed hookid: check-yaml could not determine a constructor for the tag '!vault' in "inventories/group_vars/all.yml", line 62, column 13 ``` Do you think it's possible to add this as an exception inside the hook (and make it pass for everyone who's using encypted variables in their playbooks) ? Or should I add explicit exception inside my `.pre-commit-config.yaml`, for each files where I use those encrypted variables ?
0.0
e80813e7e9bceeb263a4329341f2681074fa725a
[ "tests/check_yaml_test.py::test_check_yaml_unsafe", "tests/check_yaml_test.py::test_check_yaml_unsafe_still_fails_on_syntax_errors" ]
[ "tests/check_yaml_test.py::test_check_yaml[bad_yaml.notyaml-1]", "tests/check_yaml_test.py::test_check_yaml[ok_yaml.yaml-0]", "tests/check_yaml_test.py::test_check_yaml_allow_multiple_documents", "tests/check_yaml_test.py::test_fails_even_with_allow_multiple_documents" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2018-03-19 16:29:06+00:00
mit
4,664
pre-commit__pre-commit-hooks-327
diff --git a/pre_commit_hooks/end_of_file_fixer.py b/pre_commit_hooks/end_of_file_fixer.py index 4fe82b7..5ab1b7b 100644 --- a/pre_commit_hooks/end_of_file_fixer.py +++ b/pre_commit_hooks/end_of_file_fixer.py @@ -15,13 +15,13 @@ def fix_file(file_obj): return 0 last_character = file_obj.read(1) # last_character will be '' for an empty file - if last_character != b'\n' and last_character != b'': + if last_character not in {b'\n', b'\r'} and last_character != b'': # Needs this seek for windows, otherwise IOError file_obj.seek(0, os.SEEK_END) file_obj.write(b'\n') return 1 - while last_character == b'\n': + while last_character in {b'\n', b'\r'}: # Deal with the beginning of the file if file_obj.tell() == 1: # If we've reached the beginning of the file and it is all @@ -35,13 +35,16 @@ def fix_file(file_obj): last_character = file_obj.read(1) # Our current position is at the end of the file just before any amount of - # newlines. If we read two characters and get two newlines back we know - # there are extraneous newlines at the ned of the file. Then backtrack and - # trim the end off. - if len(file_obj.read(2)) == 2: - file_obj.seek(-1, os.SEEK_CUR) - file_obj.truncate() - return 1 + # newlines. If we find extraneous newlines, then backtrack and trim them. + position = file_obj.tell() + remaining = file_obj.read() + for sequence in (b'\n', b'\r\n', b'\r'): + if remaining == sequence: + return 0 + elif remaining.startswith(sequence): + file_obj.seek(position + len(sequence)) + file_obj.truncate() + return 1 return 0
pre-commit/pre-commit-hooks
e01bc2c2a1dc289eca5e41ea73f0942efe6e95ca
diff --git a/tests/end_of_file_fixer_test.py b/tests/end_of_file_fixer_test.py index ae899d2..f8710af 100644 --- a/tests/end_of_file_fixer_test.py +++ b/tests/end_of_file_fixer_test.py @@ -15,6 +15,10 @@ TESTS = ( (b'foo', 1, b'foo\n'), (b'foo\n\n\n', 1, b'foo\n'), (b'\xe2\x98\x83', 1, b'\xe2\x98\x83\n'), + (b'foo\r\n', 0, b'foo\r\n'), + (b'foo\r\n\r\n\r\n', 1, b'foo\r\n'), + (b'foo\r', 0, b'foo\r'), + (b'foo\r\r\r\r', 1, b'foo\r'), )
end-of-file-fixer doesn't handle CRLF When comparing the last two characters for consecutive `\n`, since `\r` doesn't match, it won't fix `\r\n\r\n\r\n` and so on. Noticed this in an old version (0.7.0), but it still applies to the latest (2.0.0) as well.
0.0
e01bc2c2a1dc289eca5e41ea73f0942efe6e95ca
[ "tests/end_of_file_fixer_test.py::test_fix_file[foo\\r\\n\\r\\n\\r\\n-1-foo\\r\\n]", "tests/end_of_file_fixer_test.py::test_fix_file[foo\\r-0-foo\\r]", "tests/end_of_file_fixer_test.py::test_fix_file[foo\\r\\r\\r\\r-1-foo\\r]", "tests/end_of_file_fixer_test.py::test_integration[foo\\r\\n\\r\\n\\r\\n-1-foo\\r\\n]", "tests/end_of_file_fixer_test.py::test_integration[foo\\r-0-foo\\r]", "tests/end_of_file_fixer_test.py::test_integration[foo\\r\\r\\r\\r-1-foo\\r]" ]
[ "tests/end_of_file_fixer_test.py::test_fix_file[foo\\n-0-foo\\n]", "tests/end_of_file_fixer_test.py::test_fix_file[-0-]", "tests/end_of_file_fixer_test.py::test_fix_file[\\n\\n-1-]", "tests/end_of_file_fixer_test.py::test_fix_file[\\n\\n\\n\\n-1-]", "tests/end_of_file_fixer_test.py::test_fix_file[foo-1-foo\\n]", "tests/end_of_file_fixer_test.py::test_fix_file[foo\\n\\n\\n-1-foo\\n]", "tests/end_of_file_fixer_test.py::test_fix_file[\\xe2\\x98\\x83-1-\\xe2\\x98\\x83\\n]", "tests/end_of_file_fixer_test.py::test_fix_file[foo\\r\\n-0-foo\\r\\n]", "tests/end_of_file_fixer_test.py::test_integration[foo\\n-0-foo\\n]", "tests/end_of_file_fixer_test.py::test_integration[-0-]", "tests/end_of_file_fixer_test.py::test_integration[\\n\\n-1-]", "tests/end_of_file_fixer_test.py::test_integration[\\n\\n\\n\\n-1-]", "tests/end_of_file_fixer_test.py::test_integration[foo-1-foo\\n]", "tests/end_of_file_fixer_test.py::test_integration[foo\\n\\n\\n-1-foo\\n]", "tests/end_of_file_fixer_test.py::test_integration[\\xe2\\x98\\x83-1-\\xe2\\x98\\x83\\n]", "tests/end_of_file_fixer_test.py::test_integration[foo\\r\\n-0-foo\\r\\n]" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2018-10-13 11:36:08+00:00
mit
4,665
pre-commit__pre-commit-hooks-386
diff --git a/pre_commit_hooks/string_fixer.py b/pre_commit_hooks/string_fixer.py index a5ea1ea..a41b737 100644 --- a/pre_commit_hooks/string_fixer.py +++ b/pre_commit_hooks/string_fixer.py @@ -31,13 +31,13 @@ def handle_match(token_text): # type: (str) -> str def get_line_offsets_by_line_no(src): # type: (str) -> List[int] # Padded so we can index with line number offsets = [-1, 0] - for line in src.splitlines(): - offsets.append(offsets[-1] + len(line) + 1) + for line in src.splitlines(True): + offsets.append(offsets[-1] + len(line)) return offsets def fix_strings(filename): # type: (str) -> int - with io.open(filename, encoding='UTF-8') as f: + with io.open(filename, encoding='UTF-8', newline='') as f: contents = f.read() line_offsets = get_line_offsets_by_line_no(contents) @@ -58,8 +58,8 @@ def fix_strings(filename): # type: (str) -> int new_contents = ''.join(splitcontents) if contents != new_contents: - with io.open(filename, 'w', encoding='UTF-8') as write_handle: - write_handle.write(new_contents) + with io.open(filename, 'w', encoding='UTF-8', newline='') as f: + f.write(new_contents) return 1 else: return 0
pre-commit/pre-commit-hooks
e8e54f7f99d61a6f60373b87ac4932d70bda58d9
diff --git a/tests/string_fixer_test.py b/tests/string_fixer_test.py index a65213b..4adca4a 100644 --- a/tests/string_fixer_test.py +++ b/tests/string_fixer_test.py @@ -44,8 +44,15 @@ TESTS = ( @pytest.mark.parametrize(('input_s', 'output', 'expected_retval'), TESTS) def test_rewrite(input_s, output, expected_retval, tmpdir): - path = tmpdir.join('file.txt') + path = tmpdir.join('file.py') path.write(input_s) retval = main([path.strpath]) assert path.read() == output assert retval == expected_retval + + +def test_rewrite_crlf(tmpdir): + f = tmpdir.join('f.py') + f.write_binary(b'"foo"\r\n"bar"\r\n') + assert main((f.strpath,)) + assert f.read_binary() == b"'foo'\r\n'bar'\r\n"
double-quote-string-fixer change linebreak on windows I'm using `mixed-line-ending` and `double-quote-string-fixer` on windows' If `double-quote-string-fixer` changes file content, origin `LF` ending will be convert to `CRLF` ending.
0.0
e8e54f7f99d61a6f60373b87ac4932d70bda58d9
[ "tests/string_fixer_test.py::test_rewrite_crlf" ]
[ "tests/string_fixer_test.py::test_rewrite[''-''-0]", "tests/string_fixer_test.py::test_rewrite[\"\"-''-1]", "tests/string_fixer_test.py::test_rewrite[\"\\\\'\"-\"\\\\'\"-0_0]", "tests/string_fixer_test.py::test_rewrite[\"\\\\\"\"-\"\\\\\"\"-0]", "tests/string_fixer_test.py::test_rewrite['\\\\\"\\\\\"'-'\\\\\"\\\\\"'-0]", "tests/string_fixer_test.py::test_rewrite[x", "tests/string_fixer_test.py::test_rewrite[\"\\\\'\"-\"\\\\'\"-0_1]", "tests/string_fixer_test.py::test_rewrite[\"\"\"", "tests/string_fixer_test.py::test_rewrite[\\nx", "tests/string_fixer_test.py::test_rewrite[\"foo\"\"bar\"-'foo''bar'-1]" ]
{ "failed_lite_validators": [ "has_short_problem_statement" ], "has_test_patch": true, "is_lite": false }
2019-05-16 16:44:11+00:00
mit
4,666
pre-commit__pre-commit-hooks-415
diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py index 4575975..eff7935 100644 --- a/pre_commit_hooks/requirements_txt_fixer.py +++ b/pre_commit_hooks/requirements_txt_fixer.py @@ -40,11 +40,16 @@ class Requirement(object): def fix_requirements(f): # type: (IO[bytes]) -> int requirements = [] # type: List[Requirement] - before = tuple(f) + before = list(f) after = [] # type: List[bytes] before_string = b''.join(before) + # adds new line in case one is missing + # AND a change to the requirements file is needed regardless: + if before and not before[-1].endswith(b'\n'): + before[-1] += b'\n' + # If the file is empty (i.e. only whitespace/newlines) exit early if before_string.strip() == b'': return PASS
pre-commit/pre-commit-hooks
277f875bc517bbde5f767dcb0919e762c33759a9
diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py index c7c6e47..2e2eab6 100644 --- a/tests/requirements_txt_fixer_test.py +++ b/tests/requirements_txt_fixer_test.py @@ -15,6 +15,9 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement (b'foo\n# comment at end\n', PASS, b'foo\n# comment at end\n'), (b'foo\nbar\n', FAIL, b'bar\nfoo\n'), (b'bar\nfoo\n', PASS, b'bar\nfoo\n'), + (b'a\nc\nb\n', FAIL, b'a\nb\nc\n'), + (b'a\nc\nb', FAIL, b'a\nb\nc\n'), + (b'a\nb\nc', FAIL, b'a\nb\nc\n'), ( b'#comment1\nfoo\n#comment2\nbar\n', FAIL,
requirements-txt-fixer corrupts file if no new line at end a file with ``` a b c ``` (no new line) will get "fixed" to: ``` a bc ``` I was able to debug and identify the issue, I'll be happy to also PR a fix but I was wondering if there is really a use for it? I've not seen any input without a new line at the end in the tests cases and as a work around I can add `end-of-file-fixer` before it.
0.0
277f875bc517bbde5f767dcb0919e762c33759a9
[ "tests/requirements_txt_fixer_test.py::test_integration[a\\nc\\nb-1-a\\nb\\nc\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a\\nb\\nc-1-a\\nb\\nc\\n]" ]
[ "tests/requirements_txt_fixer_test.py::test_integration[-0-]", "tests/requirements_txt_fixer_test.py::test_integration[\\n-0-\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#", "tests/requirements_txt_fixer_test.py::test_integration[foo\\n#", "tests/requirements_txt_fixer_test.py::test_integration[foo\\nbar\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[bar\\nfoo\\n-0-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a\\nc\\nb\\n-1-a\\nb\\nc\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment1\\nfoo\\n#comment2\\nbar\\n-1-#comment2\\nbar\\n#comment1\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment1\\nbar\\n#comment2\\nfoo\\n-0-#comment1\\nbar\\n#comment2\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment\\n\\nfoo\\nbar\\n-1-#comment\\n\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment\\n\\nbar\\nfoo\\n-0-#comment\\n\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[\\nfoo\\nbar\\n-1-bar\\n\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[\\nbar\\nfoo\\n-0-\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[pyramid==1\\npyramid-foo==2\\n-0-pyramid==1\\npyramid-foo==2\\n]", "tests/requirements_txt_fixer_test.py::test_integration[ocflib\\nDjango\\nPyMySQL\\n-1-Django\\nocflib\\nPyMySQL\\n]", "tests/requirements_txt_fixer_test.py::test_integration[-e", "tests/requirements_txt_fixer_test.py::test_integration[bar\\npkg-resources==0.0.0\\nfoo\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[foo\\npkg-resources==0.0.0\\nbar\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_requirement_object" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2019-09-28 18:44:20+00:00
mit
4,667
pre-commit__pre-commit-hooks-469
diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py index dc41815..6190692 100644 --- a/pre_commit_hooks/requirements_txt_fixer.py +++ b/pre_commit_hooks/requirements_txt_fixer.py @@ -34,6 +34,18 @@ class Requirement: else: return self.name < requirement.name + def is_complete(self) -> bool: + return ( + self.value is not None and + not self.value.rstrip(b'\r\n').endswith(b'\\') + ) + + def append_value(self, value: bytes) -> None: + if self.value is not None: + self.value += value + else: + self.value = value + def fix_requirements(f: IO[bytes]) -> int: requirements: List[Requirement] = [] @@ -55,7 +67,7 @@ def fix_requirements(f: IO[bytes]) -> int: # If the most recent requirement object has a value, then it's # time to start building the next requirement object. - if not len(requirements) or requirements[-1].value is not None: + if not len(requirements) or requirements[-1].is_complete(): requirements.append(Requirement()) requirement = requirements[-1] @@ -73,7 +85,7 @@ def fix_requirements(f: IO[bytes]) -> int: elif line.startswith(b'#') or line.strip() == b'': requirement.comments.append(line) else: - requirement.value = line + requirement.append_value(line) # if a file ends in a comment, preserve it at the end if requirements[-1].value is None:
pre-commit/pre-commit-hooks
41e26ab636aab10b8b367c9654d606604c0e5da8
diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py index 7b9b07d..17a9a41 100644 --- a/tests/requirements_txt_fixer_test.py +++ b/tests/requirements_txt_fixer_test.py @@ -50,6 +50,24 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement FAIL, b'Django\nijk\ngit+ssh://git_url@tag#egg=ocflib\n', ), + ( + b'b==1.0.0\n' + b'c=2.0.0 \\\n' + b' --hash=sha256:abcd\n' + b'a=3.0.0 \\\n' + b' --hash=sha256:a1b1c1d1', + FAIL, + b'a=3.0.0 \\\n' + b' --hash=sha256:a1b1c1d1\n' + b'b==1.0.0\n' + b'c=2.0.0 \\\n' + b' --hash=sha256:abcd\n', + ), + ( + b'a=2.0.0 \\\n --hash=sha256:abcd\nb==1.0.0\n', + PASS, + b'a=2.0.0 \\\n --hash=sha256:abcd\nb==1.0.0\n', + ), ), ) def test_integration(input_s, expected_retval, output, tmpdir):
requirements-txt-fixer does not handle multiline dependencies Given: ``` distlib==0.3.0 \ --hash=sha256:2e166e231a26b36d6dfe35a48c4464346620f8645ed0ace01ee31822b288de21 appdirs==1.4.3 \ --hash=sha256:9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92 \ --hash=sha256:d8b24664561d0d34ddfaec54636d502d7cea6e29c3eaf68f3df6180863e2166e filelock==3.0.12 \ --hash=sha256:18d82244ee114f543149c66a6e0c14e9c4f8a1044b5cdaadd0f82159d6a6ff59 \ --hash=sha256:929b7d63ec5b7d6b71b0fa5ac14e030b3f70b75747cef1b10da9b879fef15836 ``` requirements-txt-fixer will move all `--hash` lines on top of the file.
0.0
41e26ab636aab10b8b367c9654d606604c0e5da8
[ "tests/requirements_txt_fixer_test.py::test_integration[b==1.0.0\\nc=2.0.0", "tests/requirements_txt_fixer_test.py::test_integration[a=2.0.0" ]
[ "tests/requirements_txt_fixer_test.py::test_integration[-0-]", "tests/requirements_txt_fixer_test.py::test_integration[\\n-0-\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#", "tests/requirements_txt_fixer_test.py::test_integration[foo\\n#", "tests/requirements_txt_fixer_test.py::test_integration[foo\\nbar\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[bar\\nfoo\\n-0-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a\\nc\\nb\\n-1-a\\nb\\nc\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a\\nc\\nb-1-a\\nb\\nc\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a\\nb\\nc-1-a\\nb\\nc\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment1\\nfoo\\n#comment2\\nbar\\n-1-#comment2\\nbar\\n#comment1\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment1\\nbar\\n#comment2\\nfoo\\n-0-#comment1\\nbar\\n#comment2\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment\\n\\nfoo\\nbar\\n-1-#comment\\n\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment\\n\\nbar\\nfoo\\n-0-#comment\\n\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[\\nfoo\\nbar\\n-1-bar\\n\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[\\nbar\\nfoo\\n-0-\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[pyramid==1\\npyramid-foo==2\\n-0-pyramid==1\\npyramid-foo==2\\n]", "tests/requirements_txt_fixer_test.py::test_integration[ocflib\\nDjango\\nPyMySQL\\n-1-Django\\nocflib\\nPyMySQL\\n]", "tests/requirements_txt_fixer_test.py::test_integration[-e", "tests/requirements_txt_fixer_test.py::test_integration[bar\\npkg-resources==0.0.0\\nfoo\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[foo\\npkg-resources==0.0.0\\nbar\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[git+ssh://git_url@tag#egg=ocflib\\nDjango\\nijk\\n-1-Django\\nijk\\ngit+ssh://git_url@tag#egg=ocflib\\n]", "tests/requirements_txt_fixer_test.py::test_requirement_object" ]
{ "failed_lite_validators": [ "has_short_problem_statement" ], "has_test_patch": true, "is_lite": false }
2020-05-07 20:03:04+00:00
mit
4,668
pre-commit__pre-commit-hooks-480
diff --git a/pre_commit_hooks/check_executables_have_shebangs.py b/pre_commit_hooks/check_executables_have_shebangs.py index c34c7b7..1c50ea0 100644 --- a/pre_commit_hooks/check_executables_have_shebangs.py +++ b/pre_commit_hooks/check_executables_have_shebangs.py @@ -2,26 +2,60 @@ import argparse import shlex import sys +from typing import List from typing import Optional from typing import Sequence +from typing import Set +from pre_commit_hooks.util import cmd_output -def check_has_shebang(path: str) -> int: +EXECUTABLE_VALUES = frozenset(('1', '3', '5', '7')) + + +def check_executables(paths: List[str]) -> int: + if sys.platform == 'win32': # pragma: win32 cover + return _check_git_filemode(paths) + else: # pragma: win32 no cover + retv = 0 + for path in paths: + if not _check_has_shebang(path): + _message(path) + retv = 1 + + return retv + + +def _check_git_filemode(paths: Sequence[str]) -> int: + outs = cmd_output('git', 'ls-files', '--stage', '--', *paths) + seen: Set[str] = set() + for out in outs.splitlines(): + metadata, path = out.split('\t') + tagmode = metadata.split(' ', 1)[0] + + is_executable = any(b in EXECUTABLE_VALUES for b in tagmode[-3:]) + has_shebang = _check_has_shebang(path) + if is_executable and not has_shebang: + _message(path) + seen.add(path) + + return int(bool(seen)) + + +def _check_has_shebang(path: str) -> int: with open(path, 'rb') as f: first_bytes = f.read(2) - if first_bytes != b'#!': - quoted = shlex.quote(path) - print( - f'{path}: marked executable but has no (or invalid) shebang!\n' - f" If it isn't supposed to be executable, try: " - f'`chmod -x {quoted}`\n' - f' If it is supposed to be executable, double-check its shebang.', - file=sys.stderr, - ) - return 1 - else: - return 0 + return first_bytes == b'#!' + + +def _message(path: str) -> None: + print( + f'{path}: marked executable but has no (or invalid) shebang!\n' + f" If it isn't supposed to be executable, try: " + f'`chmod -x {shlex.quote(path)}`\n' + f' If it is supposed to be executable, double-check its shebang.', + file=sys.stderr, + ) def main(argv: Optional[Sequence[str]] = None) -> int: @@ -29,12 +63,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int: parser.add_argument('filenames', nargs='*') args = parser.parse_args(argv) - retv = 0 - - for filename in args.filenames: - retv |= check_has_shebang(filename) - - return retv + return check_executables(args.filenames) if __name__ == '__main__':
pre-commit/pre-commit-hooks
3d379a962d0f8bca3ad9bc59781c562b12f303b3
diff --git a/tests/check_executables_have_shebangs_test.py b/tests/check_executables_have_shebangs_test.py index 15f0c79..3b77612 100644 --- a/tests/check_executables_have_shebangs_test.py +++ b/tests/check_executables_have_shebangs_test.py @@ -1,8 +1,19 @@ +import os +import sys + import pytest +from pre_commit_hooks import check_executables_have_shebangs from pre_commit_hooks.check_executables_have_shebangs import main +from pre_commit_hooks.util import cmd_output + +skip_win32 = pytest.mark.skipif( + sys.platform == 'win32', + reason="non-git checks aren't relevant on windows", +) +@skip_win32 # pragma: win32 no cover @pytest.mark.parametrize( 'content', ( b'#!/bin/bash\nhello world\n', @@ -17,6 +28,7 @@ def test_has_shebang(content, tmpdir): assert main((path.strpath,)) == 0 +@skip_win32 # pragma: win32 no cover @pytest.mark.parametrize( 'content', ( b'', @@ -24,7 +36,6 @@ def test_has_shebang(content, tmpdir): b'\n#!python\n', b'python\n', '☃'.encode(), - ), ) def test_bad_shebang(content, tmpdir, capsys): @@ -33,3 +44,67 @@ def test_bad_shebang(content, tmpdir, capsys): assert main((path.strpath,)) == 1 _, stderr = capsys.readouterr() assert stderr.startswith(f'{path}: marked executable but') + + +def test_check_git_filemode_passing(tmpdir): + with tmpdir.as_cwd(): + cmd_output('git', 'init', '.') + + f = tmpdir.join('f') + f.write('#!/usr/bin/env bash') + f_path = str(f) + cmd_output('chmod', '+x', f_path) + cmd_output('git', 'add', f_path) + cmd_output('git', 'update-index', '--chmod=+x', f_path) + + g = tmpdir.join('g').ensure() + g_path = str(g) + cmd_output('git', 'add', g_path) + + # this is potentially a problem, but not something the script intends + # to check for -- we're only making sure that things that are + # executable have shebangs + h = tmpdir.join('h') + h.write('#!/usr/bin/env bash') + h_path = str(h) + cmd_output('git', 'add', h_path) + + files = (f_path, g_path, h_path) + assert check_executables_have_shebangs._check_git_filemode(files) == 0 + + +def test_check_git_filemode_failing(tmpdir): + with tmpdir.as_cwd(): + cmd_output('git', 'init', '.') + + f = tmpdir.join('f').ensure() + f_path = str(f) + cmd_output('chmod', '+x', f_path) + cmd_output('git', 'add', f_path) + cmd_output('git', 'update-index', '--chmod=+x', f_path) + + files = (f_path,) + assert check_executables_have_shebangs._check_git_filemode(files) == 1 + + [email protected]( + ('content', 'mode', 'expected'), + ( + pytest.param('#!python', '+x', 0, id='shebang with executable'), + pytest.param('#!python', '-x', 0, id='shebang without executable'), + pytest.param('', '+x', 1, id='no shebang with executable'), + pytest.param('', '-x', 0, id='no shebang without executable'), + ), +) +def test_git_executable_shebang(temp_git_dir, content, mode, expected): + with temp_git_dir.as_cwd(): + path = temp_git_dir.join('path') + path.write(content) + cmd_output('git', 'add', str(path)) + cmd_output('chmod', mode, str(path)) + cmd_output('git', 'update-index', f'--chmod={mode}', str(path)) + + # simulate how identify choses that something is executable + filenames = [path for path in [str(path)] if os.access(path, os.X_OK)] + + assert main(filenames) == expected
check-executables-have-shebangs not correct on windows does not seem to work right on windows i am dealing with a primarily linux / python project but on a windows machine. i have set `git config core.filemode false` i created a new file and stage and i verify that filemode is 644: ``` >git ls-files -s newfile.py 100644 3edd36f71bf2081c70a0eaf39dec6980d0a9f791 0 newfile.py ``` but hook still fails ``` hookid: check-executables-have-shebangs newfile.py: marked executable but has no (or invalid) shebang! If it isn't supposed to be executable, try: chmod -x newfile.py If it is supposed to be executable, double-check its shebang. ``` why is this file causing error?
0.0
3d379a962d0f8bca3ad9bc59781c562b12f303b3
[ "tests/check_executables_have_shebangs_test.py::test_check_git_filemode_passing", "tests/check_executables_have_shebangs_test.py::test_check_git_filemode_failing" ]
[ "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!/bin/bash\\nhello", "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!/usr/bin/env", "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!python]", "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!\\xe2\\x98\\x83]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[\\n#!python\\n]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[python\\n]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[\\xe2\\x98\\x83]", "tests/check_executables_have_shebangs_test.py::test_git_executable_shebang[shebang", "tests/check_executables_have_shebangs_test.py::test_git_executable_shebang[no" ]
{ "failed_lite_validators": [ "has_git_commit_hash" ], "has_test_patch": true, "is_lite": false }
2020-05-17 02:20:14+00:00
mit
4,669
pre-commit__pre-commit-hooks-483
diff --git a/pre_commit_hooks/check_executables_have_shebangs.py b/pre_commit_hooks/check_executables_have_shebangs.py index c34c7b7..1c50ea0 100644 --- a/pre_commit_hooks/check_executables_have_shebangs.py +++ b/pre_commit_hooks/check_executables_have_shebangs.py @@ -2,26 +2,60 @@ import argparse import shlex import sys +from typing import List from typing import Optional from typing import Sequence +from typing import Set +from pre_commit_hooks.util import cmd_output -def check_has_shebang(path: str) -> int: +EXECUTABLE_VALUES = frozenset(('1', '3', '5', '7')) + + +def check_executables(paths: List[str]) -> int: + if sys.platform == 'win32': # pragma: win32 cover + return _check_git_filemode(paths) + else: # pragma: win32 no cover + retv = 0 + for path in paths: + if not _check_has_shebang(path): + _message(path) + retv = 1 + + return retv + + +def _check_git_filemode(paths: Sequence[str]) -> int: + outs = cmd_output('git', 'ls-files', '--stage', '--', *paths) + seen: Set[str] = set() + for out in outs.splitlines(): + metadata, path = out.split('\t') + tagmode = metadata.split(' ', 1)[0] + + is_executable = any(b in EXECUTABLE_VALUES for b in tagmode[-3:]) + has_shebang = _check_has_shebang(path) + if is_executable and not has_shebang: + _message(path) + seen.add(path) + + return int(bool(seen)) + + +def _check_has_shebang(path: str) -> int: with open(path, 'rb') as f: first_bytes = f.read(2) - if first_bytes != b'#!': - quoted = shlex.quote(path) - print( - f'{path}: marked executable but has no (or invalid) shebang!\n' - f" If it isn't supposed to be executable, try: " - f'`chmod -x {quoted}`\n' - f' If it is supposed to be executable, double-check its shebang.', - file=sys.stderr, - ) - return 1 - else: - return 0 + return first_bytes == b'#!' + + +def _message(path: str) -> None: + print( + f'{path}: marked executable but has no (or invalid) shebang!\n' + f" If it isn't supposed to be executable, try: " + f'`chmod -x {shlex.quote(path)}`\n' + f' If it is supposed to be executable, double-check its shebang.', + file=sys.stderr, + ) def main(argv: Optional[Sequence[str]] = None) -> int: @@ -29,12 +63,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int: parser.add_argument('filenames', nargs='*') args = parser.parse_args(argv) - retv = 0 - - for filename in args.filenames: - retv |= check_has_shebang(filename) - - return retv + return check_executables(args.filenames) if __name__ == '__main__': diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py index 6190692..78103a1 100644 --- a/pre_commit_hooks/requirements_txt_fixer.py +++ b/pre_commit_hooks/requirements_txt_fixer.py @@ -1,4 +1,5 @@ import argparse +import re from typing import IO from typing import List from typing import Optional @@ -10,6 +11,9 @@ FAIL = 1 class Requirement: + UNTIL_COMPARISON = re.compile(b'={2,3}|!=|~=|>=?|<=?') + UNTIL_SEP = re.compile(rb'[^;\s]+') + def __init__(self) -> None: self.value: Optional[bytes] = None self.comments: List[bytes] = [] @@ -17,11 +21,20 @@ class Requirement: @property def name(self) -> bytes: assert self.value is not None, self.value + name = self.value.lower() for egg in (b'#egg=', b'&egg='): if egg in self.value: - return self.value.lower().partition(egg)[-1] + return name.partition(egg)[-1] + + m = self.UNTIL_SEP.match(name) + assert m is not None + + name = m.group() + m = self.UNTIL_COMPARISON.search(name) + if not m: + return name - return self.value.lower().partition(b'==')[0] + return name[:m.start()] def __lt__(self, requirement: 'Requirement') -> int: # \n means top of file comment, so always return True,
pre-commit/pre-commit-hooks
3d379a962d0f8bca3ad9bc59781c562b12f303b3
diff --git a/tests/check_executables_have_shebangs_test.py b/tests/check_executables_have_shebangs_test.py index 15f0c79..3b77612 100644 --- a/tests/check_executables_have_shebangs_test.py +++ b/tests/check_executables_have_shebangs_test.py @@ -1,8 +1,19 @@ +import os +import sys + import pytest +from pre_commit_hooks import check_executables_have_shebangs from pre_commit_hooks.check_executables_have_shebangs import main +from pre_commit_hooks.util import cmd_output + +skip_win32 = pytest.mark.skipif( + sys.platform == 'win32', + reason="non-git checks aren't relevant on windows", +) +@skip_win32 # pragma: win32 no cover @pytest.mark.parametrize( 'content', ( b'#!/bin/bash\nhello world\n', @@ -17,6 +28,7 @@ def test_has_shebang(content, tmpdir): assert main((path.strpath,)) == 0 +@skip_win32 # pragma: win32 no cover @pytest.mark.parametrize( 'content', ( b'', @@ -24,7 +36,6 @@ def test_has_shebang(content, tmpdir): b'\n#!python\n', b'python\n', '☃'.encode(), - ), ) def test_bad_shebang(content, tmpdir, capsys): @@ -33,3 +44,67 @@ def test_bad_shebang(content, tmpdir, capsys): assert main((path.strpath,)) == 1 _, stderr = capsys.readouterr() assert stderr.startswith(f'{path}: marked executable but') + + +def test_check_git_filemode_passing(tmpdir): + with tmpdir.as_cwd(): + cmd_output('git', 'init', '.') + + f = tmpdir.join('f') + f.write('#!/usr/bin/env bash') + f_path = str(f) + cmd_output('chmod', '+x', f_path) + cmd_output('git', 'add', f_path) + cmd_output('git', 'update-index', '--chmod=+x', f_path) + + g = tmpdir.join('g').ensure() + g_path = str(g) + cmd_output('git', 'add', g_path) + + # this is potentially a problem, but not something the script intends + # to check for -- we're only making sure that things that are + # executable have shebangs + h = tmpdir.join('h') + h.write('#!/usr/bin/env bash') + h_path = str(h) + cmd_output('git', 'add', h_path) + + files = (f_path, g_path, h_path) + assert check_executables_have_shebangs._check_git_filemode(files) == 0 + + +def test_check_git_filemode_failing(tmpdir): + with tmpdir.as_cwd(): + cmd_output('git', 'init', '.') + + f = tmpdir.join('f').ensure() + f_path = str(f) + cmd_output('chmod', '+x', f_path) + cmd_output('git', 'add', f_path) + cmd_output('git', 'update-index', '--chmod=+x', f_path) + + files = (f_path,) + assert check_executables_have_shebangs._check_git_filemode(files) == 1 + + [email protected]( + ('content', 'mode', 'expected'), + ( + pytest.param('#!python', '+x', 0, id='shebang with executable'), + pytest.param('#!python', '-x', 0, id='shebang without executable'), + pytest.param('', '+x', 1, id='no shebang with executable'), + pytest.param('', '-x', 0, id='no shebang without executable'), + ), +) +def test_git_executable_shebang(temp_git_dir, content, mode, expected): + with temp_git_dir.as_cwd(): + path = temp_git_dir.join('path') + path.write(content) + cmd_output('git', 'add', str(path)) + cmd_output('chmod', mode, str(path)) + cmd_output('git', 'update-index', f'--chmod={mode}', str(path)) + + # simulate how identify choses that something is executable + filenames = [path for path in [str(path)] if os.access(path, os.X_OK)] + + assert main(filenames) == expected diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py index 17a9a41..fae5a72 100644 --- a/tests/requirements_txt_fixer_test.py +++ b/tests/requirements_txt_fixer_test.py @@ -33,9 +33,28 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement (b'\nfoo\nbar\n', FAIL, b'bar\n\nfoo\n'), (b'\nbar\nfoo\n', PASS, b'\nbar\nfoo\n'), ( - b'pyramid==1\npyramid-foo==2\n', - PASS, - b'pyramid==1\npyramid-foo==2\n', + b'pyramid-foo==1\npyramid>=2\n', + FAIL, + b'pyramid>=2\npyramid-foo==1\n', + ), + ( + b'a==1\n' + b'c>=1\n' + b'bbbb!=1\n' + b'c-a>=1;python_version>="3.6"\n' + b'e>=2\n' + b'd>2\n' + b'g<2\n' + b'f<=2\n', + FAIL, + b'a==1\n' + b'bbbb!=1\n' + b'c>=1\n' + b'c-a>=1;python_version>="3.6"\n' + b'd>2\n' + b'e>=2\n' + b'f<=2\n' + b'g<2\n', ), (b'ocflib\nDjango\nPyMySQL\n', FAIL, b'Django\nocflib\nPyMySQL\n'), (
requirements-txt-fixer does not parse all requirements While working on #330 I noticed that the requirements-txt-fixer hook only parses a small subset of requirement specifiers. Take this example: pyramid-foo==1 pyramid>=2 `pyramid` should sort before `pyramid-foo`, but the hook interprets the `>=2` as part of the name. According to [PEP 508](https://www.python.org/dev/peps/pep-0508/) there are a couple of things that can be specified after the name (extras, versions, markers) so maybe an approach would be to use a regular expression to extract only the package name?
0.0
3d379a962d0f8bca3ad9bc59781c562b12f303b3
[ "tests/check_executables_have_shebangs_test.py::test_check_git_filemode_passing", "tests/check_executables_have_shebangs_test.py::test_check_git_filemode_failing", "tests/requirements_txt_fixer_test.py::test_integration[pyramid-foo==1\\npyramid>=2\\n-1-pyramid>=2\\npyramid-foo==1\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a==1\\nc>=1\\nbbbb!=1\\nc-a>=1;python_version>=\"3.6\"\\ne>=2\\nd>2\\ng<2\\nf<=2\\n-1-a==1\\nbbbb!=1\\nc>=1\\nc-a>=1;python_version>=\"3.6\"\\nd>2\\ne>=2\\nf<=2\\ng<2\\n]" ]
[ "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!/bin/bash\\nhello", "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!/usr/bin/env", "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!python]", "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!\\xe2\\x98\\x83]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[\\n#!python\\n]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[python\\n]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[\\xe2\\x98\\x83]", "tests/check_executables_have_shebangs_test.py::test_git_executable_shebang[shebang", "tests/check_executables_have_shebangs_test.py::test_git_executable_shebang[no", "tests/requirements_txt_fixer_test.py::test_integration[-0-]", "tests/requirements_txt_fixer_test.py::test_integration[\\n-0-\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#", "tests/requirements_txt_fixer_test.py::test_integration[foo\\n#", "tests/requirements_txt_fixer_test.py::test_integration[foo\\nbar\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[bar\\nfoo\\n-0-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a\\nc\\nb\\n-1-a\\nb\\nc\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a\\nc\\nb-1-a\\nb\\nc\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a\\nb\\nc-1-a\\nb\\nc\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment1\\nfoo\\n#comment2\\nbar\\n-1-#comment2\\nbar\\n#comment1\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment1\\nbar\\n#comment2\\nfoo\\n-0-#comment1\\nbar\\n#comment2\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment\\n\\nfoo\\nbar\\n-1-#comment\\n\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment\\n\\nbar\\nfoo\\n-0-#comment\\n\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[\\nfoo\\nbar\\n-1-bar\\n\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[\\nbar\\nfoo\\n-0-\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[ocflib\\nDjango\\nPyMySQL\\n-1-Django\\nocflib\\nPyMySQL\\n]", "tests/requirements_txt_fixer_test.py::test_integration[-e", "tests/requirements_txt_fixer_test.py::test_integration[bar\\npkg-resources==0.0.0\\nfoo\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[foo\\npkg-resources==0.0.0\\nbar\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[git+ssh://git_url@tag#egg=ocflib\\nDjango\\nijk\\n-1-Django\\nijk\\ngit+ssh://git_url@tag#egg=ocflib\\n]", "tests/requirements_txt_fixer_test.py::test_integration[b==1.0.0\\nc=2.0.0", "tests/requirements_txt_fixer_test.py::test_integration[a=2.0.0", "tests/requirements_txt_fixer_test.py::test_requirement_object" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2020-05-18 02:50:11+00:00
mit
4,670
pre-commit__pre-commit-hooks-487
diff --git a/pre_commit_hooks/removed.py b/pre_commit_hooks/removed.py index 9710b2d..60df096 100644 --- a/pre_commit_hooks/removed.py +++ b/pre_commit_hooks/removed.py @@ -5,7 +5,7 @@ from typing import Sequence def main(argv: Optional[Sequence[str]] = None) -> int: argv = argv if argv is not None else sys.argv[1:] - hookid, new_hookid, url = argv + hookid, new_hookid, url = argv[:3] raise SystemExit( f'`{hookid}` has been removed -- use `{new_hookid}` from {url}', )
pre-commit/pre-commit-hooks
37d0e19fd819ac917c9d21ff8656a7f151b95a1c
diff --git a/tests/removed_test.py b/tests/removed_test.py index 83df164..d635eb1 100644 --- a/tests/removed_test.py +++ b/tests/removed_test.py @@ -8,6 +8,7 @@ def test_always_fails(): main(( 'autopep8-wrapper', 'autopep8', 'https://github.com/pre-commit/mirrors-autopep8', + '--foo', 'bar', )) msg, = excinfo.value.args assert msg == (
error loading a removed hook when load a removed hook throw this error ``` Flake8 (removed).........................................................Failed - hook id: flake8 - exit code: 1 Traceback (most recent call last): File "/Users/pedro/.cache/pre-commit/repo3ku28fr9/py_env-python3.8/bin/pre-commit-hooks-removed", line 8, in <module> sys.exit(main()) File "/Users/pedro/.cache/pre-commit/repo3ku28fr9/py_env-python3.8/lib/python3.8/site-packages/pre_commit_hooks/removed.py", line 8, in main hookid, new_hookid, url = argv ValueError: too many values to unpack (expected 3) ```
0.0
37d0e19fd819ac917c9d21ff8656a7f151b95a1c
[ "tests/removed_test.py::test_always_fails" ]
[]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2020-05-19 02:29:48+00:00
mit
4,671
pre-commit__pre-commit-hooks-509
diff --git a/pre_commit_hooks/check_executables_have_shebangs.py b/pre_commit_hooks/check_executables_have_shebangs.py index 1c50ea0..a02d2a9 100644 --- a/pre_commit_hooks/check_executables_have_shebangs.py +++ b/pre_commit_hooks/check_executables_have_shebangs.py @@ -12,6 +12,14 @@ from pre_commit_hooks.util import cmd_output EXECUTABLE_VALUES = frozenset(('1', '3', '5', '7')) +def zsplit(s: str) -> List[str]: + s = s.strip('\0') + if s: + return s.split('\0') + else: + return [] + + def check_executables(paths: List[str]) -> int: if sys.platform == 'win32': # pragma: win32 cover return _check_git_filemode(paths) @@ -26,9 +34,9 @@ def check_executables(paths: List[str]) -> int: def _check_git_filemode(paths: Sequence[str]) -> int: - outs = cmd_output('git', 'ls-files', '--stage', '--', *paths) + outs = cmd_output('git', 'ls-files', '-z', '--stage', '--', *paths) seen: Set[str] = set() - for out in outs.splitlines(): + for out in zsplit(outs): metadata, path = out.split('\t') tagmode = metadata.split(' ', 1)[0]
pre-commit/pre-commit-hooks
5372f44b858f6eef834d9632e9960c39c296d448
diff --git a/tests/check_executables_have_shebangs_test.py b/tests/check_executables_have_shebangs_test.py index 5895a2a..7046081 100644 --- a/tests/check_executables_have_shebangs_test.py +++ b/tests/check_executables_have_shebangs_test.py @@ -73,6 +73,21 @@ def test_check_git_filemode_passing(tmpdir): assert check_executables_have_shebangs._check_git_filemode(files) == 0 +def test_check_git_filemode_passing_unusual_characters(tmpdir): + with tmpdir.as_cwd(): + cmd_output('git', 'init', '.') + + f = tmpdir.join('mañana.txt') + f.write('#!/usr/bin/env bash') + f_path = str(f) + cmd_output('chmod', '+x', f_path) + cmd_output('git', 'add', f_path) + cmd_output('git', 'update-index', '--chmod=+x', f_path) + + files = (f_path,) + assert check_executables_have_shebangs._check_git_filemode(files) == 0 + + def test_check_git_filemode_failing(tmpdir): with tmpdir.as_cwd(): cmd_output('git', 'init', '.') @@ -87,6 +102,16 @@ def test_check_git_filemode_failing(tmpdir): assert check_executables_have_shebangs._check_git_filemode(files) == 1 [email protected]('out', ('\0f1\0f2\0', '\0f1\0f2', 'f1\0f2\0')) +def test_check_zsplits_correctly(out): + assert check_executables_have_shebangs.zsplit(out) == ['f1', 'f2'] + + [email protected]('out', ('\0\0', '\0', '')) +def test_check_zsplit_returns_empty(out): + assert check_executables_have_shebangs.zsplit(out) == [] + + @pytest.mark.parametrize( ('content', 'mode', 'expected'), (
Filenames with unusual characters break check_executables_have_shebangs The `check_executables_have_shebangs` gets file paths with the output of the following git command: ``` git ls-files --stage -- path1 path2 ``` I'm not sure about Linux, but on Windows, when the filename contains an unusual character (sorry about the choice of "unusual" to describe the character, I don't want to speculate on encoding issues), the character is escaped with integer sequences, and git wraps the file path in double-quotes (because of the backslashes I guess): ```console $ git ls-files --stage -- tests/demo/doc/mañana.txt tests/demo/doc/manana.txt 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 tests/demo/doc/manana.txt 100644 5ab9dcdd36df0f76f202227ecb7ae8a5baaa456b 0 "tests/demo/doc/ma\303\261ana.txt" ``` The resulting path variable becomes `"tests/demo/doc/ma\303\261ana.txt"`, and then the script tries to `open` it, which fails of course because of the quotes and escaping: ``` Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\user\.cache\pre-commit\repofzzr3u3t\py_env-python3\Scripts\check-executables-have-shebangs.EXE\__main__.py", line 7, in <module> File "c:\users\user\.cache\pre-commit\repofzzr3u3t\py_env-python3\lib\site-packages\pre_commit_hooks\check_executables_have_shebangs.py", line 66, in main return check_executables(args.filenames) File "c:\users\user\.cache\pre-commit\repofzzr3u3t\py_env-python3\lib\site-packages\pre_commit_hooks\check_executables_have_shebangs.py", line 17, in check_executables return _check_git_filemode(paths) File "c:\users\user\.cache\pre-commit\repofzzr3u3t\py_env-python3\lib\site-packages\pre_commit_hooks\check_executables_have_shebangs.py", line 36, in _check_git_filemode has_shebang = _check_has_shebang(path) File "c:\users\user\.cache\pre-commit\repofzzr3u3t\py_env-python3\lib\site-packages\pre_commit_hooks\check_executables_have_shebangs.py", line 45, in _check_has_shebang with open(path, 'rb') as f: OSError: [Errno 22] Invalid argument: '"tests/demo/doc/ma\\303\\261ana.txt"' ``` To fix the quotes issue, the pre-commit script could try to remove them with a `.strip('"')` call. For the character escaping, I have no idea! Do you 😄 ? Ref: https://github.com/copier-org/copier/pull/224#issuecomment-665079662
0.0
5372f44b858f6eef834d9632e9960c39c296d448
[ "tests/check_executables_have_shebangs_test.py::test_check_git_filemode_passing_unusual_characters", "tests/check_executables_have_shebangs_test.py::test_check_zsplits_correctly[\\x00f1\\x00f2\\x00]", "tests/check_executables_have_shebangs_test.py::test_check_zsplits_correctly[\\x00f1\\x00f2]", "tests/check_executables_have_shebangs_test.py::test_check_zsplits_correctly[f1\\x00f2\\x00]", "tests/check_executables_have_shebangs_test.py::test_check_zsplit_returns_empty[\\x00\\x00]", "tests/check_executables_have_shebangs_test.py::test_check_zsplit_returns_empty[\\x00]", "tests/check_executables_have_shebangs_test.py::test_check_zsplit_returns_empty[]" ]
[ "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!/bin/bash\\nhello", "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!/usr/bin/env", "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!python]", "tests/check_executables_have_shebangs_test.py::test_has_shebang[#!\\xe2\\x98\\x83]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[\\n#!python\\n]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[python\\n]", "tests/check_executables_have_shebangs_test.py::test_bad_shebang[\\xe2\\x98\\x83]", "tests/check_executables_have_shebangs_test.py::test_check_git_filemode_passing", "tests/check_executables_have_shebangs_test.py::test_check_git_filemode_failing", "tests/check_executables_have_shebangs_test.py::test_git_executable_shebang[shebang", "tests/check_executables_have_shebangs_test.py::test_git_executable_shebang[no" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_git_commit_hash" ], "has_test_patch": true, "is_lite": false }
2020-07-29 07:57:45+00:00
mit
4,672
pre-commit__pre-commit-hooks-519
diff --git a/README.md b/README.md index 3552721..a6b62ab 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,11 @@ Add this to your `.pre-commit-config.yaml` #### `check-added-large-files` Prevent giant files from being committed. - Specify what is "too large" with `args: ['--maxkb=123']` (default=500kB). + - Limits checked files to those indicated as staged for addition by git. - If `git-lfs` is installed, lfs files will be skipped (requires `git-lfs>=2.2.1`) + - `--enforce-all` - Check all listed files not just those staged for + addition. #### `check-ast` Simply check whether files parse as valid python. diff --git a/pre_commit_hooks/check_added_large_files.py b/pre_commit_hooks/check_added_large_files.py index 91f5754..cb646d7 100644 --- a/pre_commit_hooks/check_added_large_files.py +++ b/pre_commit_hooks/check_added_large_files.py @@ -21,11 +21,20 @@ def lfs_files() -> Set[str]: return set(json.loads(lfs_ret)['files']) -def find_large_added_files(filenames: Sequence[str], maxkb: int) -> int: +def find_large_added_files( + filenames: Sequence[str], + maxkb: int, + *, + enforce_all: bool = False, +) -> int: # Find all added files that are also in the list of files pre-commit tells # us about retv = 0 - for filename in (added_files() & set(filenames)) - lfs_files(): + filenames_filtered = set(filenames) - lfs_files() + if not enforce_all: + filenames_filtered &= added_files() + + for filename in filenames_filtered: kb = int(math.ceil(os.stat(filename).st_size / 1024)) if kb > maxkb: print(f'{filename} ({kb} KB) exceeds {maxkb} KB.') @@ -40,13 +49,21 @@ def main(argv: Optional[Sequence[str]] = None) -> int: 'filenames', nargs='*', help='Filenames pre-commit believes are changed.', ) + parser.add_argument( + '--enforce-all', action='store_true', + help='Enforce all files are checked, not just staged files.', + ) parser.add_argument( '--maxkb', type=int, default=500, help='Maxmimum allowable KB for added files', ) - args = parser.parse_args(argv) - return find_large_added_files(args.filenames, args.maxkb) + + return find_large_added_files( + args.filenames, + args.maxkb, + enforce_all=args.enforce_all, + ) if __name__ == '__main__':
pre-commit/pre-commit-hooks
31d41ff29115a87808277ee0ec23999b17d5b583
diff --git a/tests/check_added_large_files_test.py b/tests/check_added_large_files_test.py index 40ffd24..ff53b05 100644 --- a/tests/check_added_large_files_test.py +++ b/tests/check_added_large_files_test.py @@ -40,6 +40,17 @@ def test_add_something_giant(temp_git_dir): assert find_large_added_files(['f.py'], 10) == 0 +def test_enforce_all(temp_git_dir): + with temp_git_dir.as_cwd(): + temp_git_dir.join('f.py').write('a' * 10000) + + # Should fail, when not staged with enforce_all + assert find_large_added_files(['f.py'], 0, enforce_all=True) == 1 + + # Should pass, when not staged without enforce_all + assert find_large_added_files(['f.py'], 0, enforce_all=False) == 0 + + def test_added_file_not_in_pre_commits_list(temp_git_dir): with temp_git_dir.as_cwd(): temp_git_dir.join('f.py').write("print('hello world')") @@ -97,3 +108,15 @@ def test_moves_with_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover # Now move it and make sure the hook still succeeds cmd_output('git', 'mv', 'a.bin', 'b.bin') assert main(('--maxkb', '9', 'b.bin')) == 0 + + +@xfailif_no_gitlfs +def test_enforce_allows_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover + with temp_git_dir.as_cwd(): + monkeypatch.setenv('HOME', str(temp_git_dir)) + cmd_output('git', 'lfs', 'install') + temp_git_dir.join('f.py').write('a' * 10000) + cmd_output('git', 'lfs', 'track', 'f.py') + cmd_output('git', 'add', '--', '.') + # With --enforce-all large files on git lfs should succeed + assert main(('--enforce-all', '--maxkb', '9', 'f.py')) == 0
check-added-large-files does not check files when run in a CI loop check-added-large-files works as expected when executed as a pre-commit hook, but when executed in a CI loop via run --all-files it does not diagnose over size files. This appears to be because the list of files provided on the command line is filtered to remove files that are not reported as staged for addition by git diff. Hence if a developer chooses not to install pre-commit as a git hook and adds an over size file, this will not subsequently be picked up by pre-commit running in CI.
0.0
31d41ff29115a87808277ee0ec23999b17d5b583
[ "tests/check_added_large_files_test.py::test_enforce_all" ]
[ "tests/check_added_large_files_test.py::test_nothing_added", "tests/check_added_large_files_test.py::test_adding_something", "tests/check_added_large_files_test.py::test_add_something_giant", "tests/check_added_large_files_test.py::test_added_file_not_in_pre_commits_list", "tests/check_added_large_files_test.py::test_integration" ]
{ "failed_lite_validators": [ "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2020-09-24 22:21:14+00:00
mit
4,673
pre-commit__pre-commit-hooks-575
diff --git a/pre_commit_hooks/check_case_conflict.py b/pre_commit_hooks/check_case_conflict.py index 6b8ba82..024c1c3 100644 --- a/pre_commit_hooks/check_case_conflict.py +++ b/pre_commit_hooks/check_case_conflict.py @@ -1,5 +1,7 @@ import argparse +import os.path from typing import Iterable +from typing import Iterator from typing import Optional from typing import Sequence from typing import Set @@ -12,9 +14,22 @@ def lower_set(iterable: Iterable[str]) -> Set[str]: return {x.lower() for x in iterable} +def parents(file: str) -> Iterator[str]: + file = os.path.dirname(file) + while file: + yield file + file = os.path.dirname(file) + + +def directories_for(files: Set[str]) -> Set[str]: + return {parent for file in files for parent in parents(file)} + + def find_conflicting_filenames(filenames: Sequence[str]) -> int: repo_files = set(cmd_output('git', 'ls-files').splitlines()) + repo_files |= directories_for(repo_files) relevant_files = set(filenames) | added_files() + relevant_files |= directories_for(relevant_files) repo_files -= relevant_files retv = 0
pre-commit/pre-commit-hooks
3db0cc5b2e2311e610a82f5048a70098eca23a07
diff --git a/tests/check_case_conflict_test.py b/tests/check_case_conflict_test.py index 53de852..c8c9d12 100644 --- a/tests/check_case_conflict_test.py +++ b/tests/check_case_conflict_test.py @@ -1,7 +1,24 @@ +import sys + +import pytest + from pre_commit_hooks.check_case_conflict import find_conflicting_filenames from pre_commit_hooks.check_case_conflict import main +from pre_commit_hooks.check_case_conflict import parents from pre_commit_hooks.util import cmd_output +skip_win32 = pytest.mark.skipif( + sys.platform == 'win32', + reason='case conflicts between directories and files', +) + + +def test_parents(): + assert set(parents('a')) == set() + assert set(parents('a/b')) == {'a'} + assert set(parents('a/b/c')) == {'a/b', 'a'} + assert set(parents('a/b/c/d')) == {'a/b/c', 'a/b', 'a'} + def test_nothing_added(temp_git_dir): with temp_git_dir.as_cwd(): @@ -26,6 +43,36 @@ def test_adding_something_with_conflict(temp_git_dir): assert find_conflicting_filenames(['f.py', 'F.py']) == 1 +@skip_win32 # pragma: win32 no cover +def test_adding_files_with_conflicting_directories(temp_git_dir): + with temp_git_dir.as_cwd(): + temp_git_dir.mkdir('dir').join('x').write('foo') + temp_git_dir.mkdir('DIR').join('y').write('foo') + cmd_output('git', 'add', '-A') + + assert find_conflicting_filenames([]) == 1 + + +@skip_win32 # pragma: win32 no cover +def test_adding_files_with_conflicting_deep_directories(temp_git_dir): + with temp_git_dir.as_cwd(): + temp_git_dir.mkdir('x').mkdir('y').join('z').write('foo') + temp_git_dir.join('X').write('foo') + cmd_output('git', 'add', '-A') + + assert find_conflicting_filenames([]) == 1 + + +@skip_win32 # pragma: win32 no cover +def test_adding_file_with_conflicting_directory(temp_git_dir): + with temp_git_dir.as_cwd(): + temp_git_dir.mkdir('dir').join('x').write('foo') + temp_git_dir.join('DIR').write('foo') + cmd_output('git', 'add', '-A') + + assert find_conflicting_filenames([]) == 1 + + def test_added_file_not_in_pre_commits_list(temp_git_dir): with temp_git_dir.as_cwd(): temp_git_dir.join('f.py').write("print('hello world')") @@ -46,6 +93,19 @@ def test_file_conflicts_with_committed_file(temp_git_dir): assert find_conflicting_filenames(['F.py']) == 1 +@skip_win32 # pragma: win32 no cover +def test_file_conflicts_with_committed_dir(temp_git_dir): + with temp_git_dir.as_cwd(): + temp_git_dir.mkdir('dir').join('x').write('foo') + cmd_output('git', 'add', '-A') + cmd_output('git', 'commit', '--no-gpg-sign', '-n', '-m', 'Add f.py') + + temp_git_dir.join('DIR').write('foo') + cmd_output('git', 'add', '-A') + + assert find_conflicting_filenames([]) == 1 + + def test_integration(temp_git_dir): with temp_git_dir.as_cwd(): assert main(argv=[]) == 0
check-case-conflict doesn't notice directory name conflicts ``` $ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: TEST/foo new file: test/bar $ git commit -m "Test" Check for case conflicts...................................................................................Passed [master (root-commit) 6931ba5] Test 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 TEST/foo create mode 100644 test/bar $ cat .pre-commit-config.yaml - repo: git://github.com/pre-commit/pre-commit-hooks sha: '0d88124ef6343fbbc6c9d2872853f73546c98a3f' hooks: - id: check-case-conflict ``` A conflict such as `Test/foo` and `test/foo` is caught though.
0.0
3db0cc5b2e2311e610a82f5048a70098eca23a07
[ "tests/check_case_conflict_test.py::test_parents", "tests/check_case_conflict_test.py::test_nothing_added", "tests/check_case_conflict_test.py::test_adding_something", "tests/check_case_conflict_test.py::test_adding_something_with_conflict", "tests/check_case_conflict_test.py::test_adding_files_with_conflicting_directories", "tests/check_case_conflict_test.py::test_adding_files_with_conflicting_deep_directories", "tests/check_case_conflict_test.py::test_adding_file_with_conflicting_directory", "tests/check_case_conflict_test.py::test_added_file_not_in_pre_commits_list", "tests/check_case_conflict_test.py::test_integration" ]
[]
{ "failed_lite_validators": [ "has_git_commit_hash" ], "has_test_patch": true, "is_lite": false }
2021-03-19 00:03:44+00:00
mit
4,674
pre-commit__pre-commit-hooks-582
diff --git a/pre_commit_hooks/check_vcs_permalinks.py b/pre_commit_hooks/check_vcs_permalinks.py index a30277c..5231d7a 100644 --- a/pre_commit_hooks/check_vcs_permalinks.py +++ b/pre_commit_hooks/check_vcs_permalinks.py @@ -8,7 +8,10 @@ from typing import Sequence def _get_pattern(domain: str) -> Pattern[bytes]: - regex = rf'https://{domain}/[^/ ]+/[^/ ]+/blob/master/[^# ]+#L\d+' + regex = ( + rf'https://{domain}/[^/ ]+/[^/ ]+/blob/' + r'(?![a-fA-F0-9]{4,64}/)([^/. ]+)/[^# ]+#L\d+' + ) return re.compile(regex.encode())
pre-commit/pre-commit-hooks
4195f4d271955e83e9d7d192f5a047c95eb6fb31
diff --git a/tests/check_vcs_permalinks_test.py b/tests/check_vcs_permalinks_test.py index 7d5f86c..ad59151 100644 --- a/tests/check_vcs_permalinks_test.py +++ b/tests/check_vcs_permalinks_test.py @@ -11,6 +11,8 @@ def test_passing(tmpdir): f.write_binary( # permalinks are ok b'https://github.com/asottile/test/blob/649e6/foo%20bar#L1\n' + # tags are ok + b'https://github.com/asottile/test/blob/1.0.0/foo%20bar#L1\n' # links to files but not line numbers are ok b'https://github.com/asottile/test/blob/master/foo%20bar\n' # regression test for overly-greedy regex @@ -23,7 +25,8 @@ def test_failing(tmpdir, capsys): with tmpdir.as_cwd(): tmpdir.join('f.txt').write_binary( b'https://github.com/asottile/test/blob/master/foo#L1\n' - b'https://example.com/asottile/test/blob/master/foo#L1\n', + b'https://example.com/asottile/test/blob/master/foo#L1\n' + b'https://example.com/asottile/test/blob/main/foo#L1\n', ) assert main(('f.txt', '--additional-github-domain', 'example.com')) @@ -31,6 +34,7 @@ def test_failing(tmpdir, capsys): assert out == ( 'f.txt:1:https://github.com/asottile/test/blob/master/foo#L1\n' 'f.txt:2:https://example.com/asottile/test/blob/master/foo#L1\n' + 'f.txt:3:https://example.com/asottile/test/blob/main/foo#L1\n' '\n' 'Non-permanent github link detected.\n' 'On any page on github press [y] to load a permalink.\n'
`check-vcs-permalinks` - Add support for different branch names Not all repositories use `master` for their branch name so it would be great if this hook could support other branch names. Preferably, this would match any blob link that doesn't contain a full hash (so *only* matching 0-f with len of 40 or 64) but if you don't consider that to be a good solution, then being able to specify a list of branches to match would also work, though it would be a lot more likely to lead to non-permalinks not getting matched.
0.0
4195f4d271955e83e9d7d192f5a047c95eb6fb31
[ "tests/check_vcs_permalinks_test.py::test_failing" ]
[ "tests/check_vcs_permalinks_test.py::test_trivial", "tests/check_vcs_permalinks_test.py::test_passing" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2021-04-06 18:35:30+00:00
mit
4,675
pre-commit__pre-commit-hooks-850
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d6d291..937696b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -23,7 +23,7 @@ repos: hooks: - id: add-trailing-comma - repo: https://github.com/asottile/pyupgrade - rev: v3.15.1 + rev: v3.15.2 hooks: - id: pyupgrade args: [--py38-plus] diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index c0d811c..4b4d0cf 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -145,7 +145,7 @@ language: python types: [text] - id: fix-encoding-pragma - name: fix python encoding pragma + name: fix python encoding pragma (deprecated) description: 'adds # -*- coding: utf-8 -*- to the top of python files.' language: python entry: fix-encoding-pragma diff --git a/CHANGELOG.md b/CHANGELOG.md index c1daaba..bf99d9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +4.6.0 - 2024-04-06 +================== + +### Features +- `requirements-txt-fixer`: remove duplicate packages. + - #1014 PR by @vhoulbreque-withings. + - #960 issue @csibe17. + +### Migrating +- `fix-encoding-pragma`: deprecated -- will be removed in 5.0.0. use + [pyupgrade](https://github.com/asottile/pyupgrade) or some other tool. + - #1033 PR by @mxr. + - #1032 issue by @mxr. + 4.5.0 - 2023-10-07 ================== diff --git a/README.md b/README.md index 9ae7ec5..4992baf 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Add this to your `.pre-commit-config.yaml` ```yaml - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 # Use the ref you want to point at + rev: v4.6.0 # Use the ref you want to point at hooks: - id: trailing-whitespace # - id: ... @@ -127,6 +127,9 @@ The following arguments are available: removes UTF-8 byte order marker #### `fix-encoding-pragma` + +_Deprecated since py2 is EOL - use [pyupgrade](https://github.com/asottile/pyupgrade) instead._ + Add `# -*- coding: utf-8 -*-` to the top of python files. - To remove the coding pragma pass `--remove` (useful in a python3-only codebase) diff --git a/pre_commit_hooks/fix_encoding_pragma.py b/pre_commit_hooks/fix_encoding_pragma.py index 60c71ee..eee6705 100644 --- a/pre_commit_hooks/fix_encoding_pragma.py +++ b/pre_commit_hooks/fix_encoding_pragma.py @@ -1,6 +1,7 @@ from __future__ import annotations import argparse +import sys from typing import IO from typing import NamedTuple from typing import Sequence @@ -107,6 +108,13 @@ def _normalize_pragma(pragma: str) -> bytes: def main(argv: Sequence[str] | None = None) -> int: + print( + 'warning: this hook is deprecated and will be removed in a future ' + 'release because py2 is EOL. instead, use ' + 'https://github.com/asottile/pyupgrade', + file=sys.stderr, + ) + parser = argparse.ArgumentParser( 'Fixes the encoding pragma of python files', ) diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py index 261acc9..07b57e1 100644 --- a/pre_commit_hooks/requirements_txt_fixer.py +++ b/pre_commit_hooks/requirements_txt_fixer.py @@ -115,7 +115,10 @@ def fix_requirements(f: IO[bytes]) -> int: # which is automatically added by broken pip package under Debian requirements = [ req for req in requirements - if req.value != b'pkg-resources==0.0.0\n' + if req.value not in [ + b'pkg-resources==0.0.0\n', + b'pkg_resources==0.0.0\n', + ] ] # sort the requirements and remove duplicates diff --git a/setup.cfg b/setup.cfg index 6a4c459..82a5457 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pre_commit_hooks -version = 4.5.0 +version = 4.6.0 description = Some out-of-the-box hooks for pre-commit. long_description = file: README.md long_description_content_type = text/markdown
pre-commit/pre-commit-hooks
6afc57465d8bad6241dca74537f57193192a0231
diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py index c400be1..c0d2c65 100644 --- a/tests/requirements_txt_fixer_test.py +++ b/tests/requirements_txt_fixer_test.py @@ -82,6 +82,8 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement ), (b'bar\npkg-resources==0.0.0\nfoo\n', FAIL, b'bar\nfoo\n'), (b'foo\npkg-resources==0.0.0\nbar\n', FAIL, b'bar\nfoo\n'), + (b'bar\npkg_resources==0.0.0\nfoo\n', FAIL, b'bar\nfoo\n'), + (b'foo\npkg_resources==0.0.0\nbar\n', FAIL, b'bar\nfoo\n'), ( b'git+ssh://git_url@tag#egg=ocflib\nDjango\nijk\n', FAIL,
requirements-txt-fixer doesn't handle new pkg_resources==0.0.0 Perhaps something changed on PyPI but instead of Ubuntu 20.04 generating `pkg-resources==0.0.0` it now generates `npkg_resources==0.0.0` which should also be ignored.
0.0
6afc57465d8bad6241dca74537f57193192a0231
[ "tests/requirements_txt_fixer_test.py::test_integration[bar\\npkg_resources==0.0.0\\nfoo\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[foo\\npkg_resources==0.0.0\\nbar\\n-1-bar\\nfoo\\n]" ]
[ "tests/requirements_txt_fixer_test.py::test_integration[-0-]", "tests/requirements_txt_fixer_test.py::test_integration[\\n-0-\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#", "tests/requirements_txt_fixer_test.py::test_integration[foo\\n#", "tests/requirements_txt_fixer_test.py::test_integration[foo\\nbar\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[bar\\nfoo\\n-0-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a\\nc\\nb\\n-1-a\\nb\\nc\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a\\nc\\nb-1-a\\nb\\nc\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a\\nb\\nc-1-a\\nb\\nc\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment1\\nfoo\\n#comment2\\nbar\\n-1-#comment2\\nbar\\n#comment1\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment1\\nbar\\n#comment2\\nfoo\\n-0-#comment1\\nbar\\n#comment2\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment\\n\\nfoo\\nbar\\n-1-#comment\\n\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[#comment\\n\\nbar\\nfoo\\n-0-#comment\\n\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[foo\\n\\t#comment", "tests/requirements_txt_fixer_test.py::test_integration[bar\\n\\t#comment", "tests/requirements_txt_fixer_test.py::test_integration[\\nfoo\\nbar\\n-1-bar\\n\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[\\nbar\\nfoo\\n-0-\\nbar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[pyramid-foo==1\\npyramid>=2\\n-1-pyramid>=2\\npyramid-foo==1\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a==1\\nc>=1\\nbbbb!=1\\nc-a>=1;python_version>=\"3.6\"\\ne>=2\\nd>2\\ng<2\\nf<=2\\n-1-a==1\\nbbbb!=1\\nc>=1\\nc-a>=1;python_version>=\"3.6\"\\nd>2\\ne>=2\\nf<=2\\ng<2\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a==1\\nb==1\\na==1\\n-1-a==1\\nb==1\\n]", "tests/requirements_txt_fixer_test.py::test_integration[a==1\\nb==1\\n#comment", "tests/requirements_txt_fixer_test.py::test_integration[ocflib\\nDjango\\nPyMySQL\\n-1-Django\\nocflib\\nPyMySQL\\n]", "tests/requirements_txt_fixer_test.py::test_integration[-e", "tests/requirements_txt_fixer_test.py::test_integration[bar\\npkg-resources==0.0.0\\nfoo\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[foo\\npkg-resources==0.0.0\\nbar\\n-1-bar\\nfoo\\n]", "tests/requirements_txt_fixer_test.py::test_integration[git+ssh://git_url@tag#egg=ocflib\\nDjango\\nijk\\n-1-Django\\nijk\\ngit+ssh://git_url@tag#egg=ocflib\\n]", "tests/requirements_txt_fixer_test.py::test_integration[b==1.0.0\\nc=2.0.0", "tests/requirements_txt_fixer_test.py::test_integration[a=2.0.0", "tests/requirements_txt_fixer_test.py::test_requirement_object" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2022-12-14 15:42:52+00:00
mit
4,676
pre-commit__pre-commit-hooks-944
diff --git a/pre_commit_hooks/file_contents_sorter.py b/pre_commit_hooks/file_contents_sorter.py index c5691f0..02bdbcc 100644 --- a/pre_commit_hooks/file_contents_sorter.py +++ b/pre_commit_hooks/file_contents_sorter.py @@ -37,7 +37,10 @@ def sort_file_contents( after = sorted(lines, key=key) before_string = b''.join(before) - after_string = b'\n'.join(after) + b'\n' + after_string = b'\n'.join(after) + + if after_string: + after_string += b'\n' if before_string == after_string: return PASS
pre-commit/pre-commit-hooks
1790c6b40aa27ce48236525540a5150493cf8fef
diff --git a/tests/file_contents_sorter_test.py b/tests/file_contents_sorter_test.py index 5e79e40..49b3b79 100644 --- a/tests/file_contents_sorter_test.py +++ b/tests/file_contents_sorter_test.py @@ -10,7 +10,9 @@ from pre_commit_hooks.file_contents_sorter import PASS @pytest.mark.parametrize( ('input_s', 'argv', 'expected_retval', 'output'), ( - (b'', [], FAIL, b'\n'), + (b'', [], PASS, b''), + (b'\n', [], FAIL, b''), + (b'\n\n', [], FAIL, b''), (b'lonesome\n', [], PASS, b'lonesome\n'), (b'missing_newline', [], FAIL, b'missing_newline\n'), (b'newline\nmissing', [], FAIL, b'missing\nnewline\n'),
`file-contents-sorter` adds an extra blank line if the file to be sorted is empty I am on `v.4.4.0`, Python `3.11.4`, macOS Ventura `13.4.1`. My `.pre-commit-config.yaml`: ```yaml repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: "v4.4.0" hooks: - id: end-of-file-fixer - id: file-contents-sorter files: ^requirements\/.+\.in$ # args: [--unique, --ignore-case] ``` The files are intentionally **empty** &ndash; I'm in the planning stage, they are just placeholders for requriements[^1]. To the point: `file-contents-sorter` adds an extra blank to them, what results in a confict with `end-of-file-fixer`. I am not sure if that is the expected behavior... Updating `args` doesn't have any effect. ```bash $ git:(install-and-configure-pre-commit) : pre-commit run --all-files fix end of files.........................................................Failed - hook id: end-of-file-fixer - exit code: 1 - files were modified by this hook Fixing requirements/build.in Fixing requirements/lint.in Fixing requirements/test.in file contents sorter.....................................................Failed - hook id: file-contents-sorter - exit code: 1 - files were modified by this hook Sorting requirements/build.in Sorting requirements/lint.in Sorting requirements/test.in ``` [^1]: Yes, I know that I can use `requirements-txt-fixer` particularly for requirements. 😄 I will do. For that issue it doesn't matter.
0.0
1790c6b40aa27ce48236525540a5150493cf8fef
[ "tests/file_contents_sorter_test.py::test_integration[-argv0-0-]", "tests/file_contents_sorter_test.py::test_integration[\\n-argv1-1-]", "tests/file_contents_sorter_test.py::test_integration[\\n\\n-argv2-1-]" ]
[ "tests/file_contents_sorter_test.py::test_integration[lonesome\\n-argv3-0-lonesome\\n]", "tests/file_contents_sorter_test.py::test_integration[missing_newline-argv4-1-missing_newline\\n]", "tests/file_contents_sorter_test.py::test_integration[newline\\nmissing-argv5-1-missing\\nnewline\\n]", "tests/file_contents_sorter_test.py::test_integration[missing\\nnewline-argv6-1-missing\\nnewline\\n]", "tests/file_contents_sorter_test.py::test_integration[alpha\\nbeta\\n-argv7-0-alpha\\nbeta\\n]", "tests/file_contents_sorter_test.py::test_integration[beta\\nalpha\\n-argv8-1-alpha\\nbeta\\n]", "tests/file_contents_sorter_test.py::test_integration[C\\nc\\n-argv9-0-C\\nc\\n]", "tests/file_contents_sorter_test.py::test_integration[c\\nC\\n-argv10-1-C\\nc\\n]", "tests/file_contents_sorter_test.py::test_integration[mag", "tests/file_contents_sorter_test.py::test_integration[@\\n-\\n_\\n#\\n-argv12-1-#\\n-\\n@\\n_\\n]", "tests/file_contents_sorter_test.py::test_integration[extra\\n\\n\\nwhitespace\\n-argv13-1-extra\\nwhitespace\\n]", "tests/file_contents_sorter_test.py::test_integration[whitespace\\n\\n\\nextra\\n-argv14-1-extra\\nwhitespace\\n]", "tests/file_contents_sorter_test.py::test_integration[fee\\nFie\\nFoe\\nfum\\n-argv15-1-Fie\\nFoe\\nfee\\nfum\\n]", "tests/file_contents_sorter_test.py::test_integration[Fie\\nFoe\\nfee\\nfum\\n-argv16-0-Fie\\nFoe\\nfee\\nfum\\n]", "tests/file_contents_sorter_test.py::test_integration[fee\\nFie\\nFoe\\nfum\\n-argv17-0-fee\\nFie\\nFoe\\nfum\\n]", "tests/file_contents_sorter_test.py::test_integration[Fie\\nFoe\\nfee\\nfum\\n-argv18-1-fee\\nFie\\nFoe\\nfum\\n]", "tests/file_contents_sorter_test.py::test_integration[Fie\\nFoe\\nfee\\nfee\\nfum\\n-argv19-1-fee\\nfee\\nFie\\nFoe\\nfum\\n]", "tests/file_contents_sorter_test.py::test_integration[Fie\\nFoe\\nfee\\nfum\\n-argv20-0-Fie\\nFoe\\nfee\\nfum\\n]", "tests/file_contents_sorter_test.py::test_integration[Fie\\nFie\\nFoe\\nfee\\nfum\\n-argv21-1-Fie\\nFoe\\nfee\\nfum\\n]", "tests/file_contents_sorter_test.py::test_integration[fee\\nFie\\nFoe\\nfum\\n-argv22-0-fee\\nFie\\nFoe\\nfum\\n]", "tests/file_contents_sorter_test.py::test_integration[fee\\nfee\\nFie\\nFoe\\nfum\\n-argv23-1-fee\\nFie\\nFoe\\nfum\\n]" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2023-08-05 21:00:44+00:00
mit
4,677
prefab-cloud__prefab-cloud-python-61
diff --git a/prefab_cloud_python/config_client.py b/prefab_cloud_python/config_client.py index 7b25208..2d56c6e 100644 --- a/prefab_cloud_python/config_client.py +++ b/prefab_cloud_python/config_client.py @@ -55,6 +55,7 @@ class ConfigClient: self.checkpoint_freq_secs = 60 self.config_loader = ConfigLoader(base_client) self.config_resolver = ConfigResolver(base_client, self.config_loader) + self._cache_path = None self.set_cache_path() if self.options.is_local_only(): @@ -209,6 +210,8 @@ class ConfigClient: def cache_configs(self, configs): if not self.options.use_local_cache: return + if not self.cache_path: + return with open(self.cache_path, "w") as f: f.write(MessageToJson(configs)) logger.debug(f"Cached configs to {self.cache_path}") @@ -216,6 +219,8 @@ class ConfigClient: def load_cache(self): if not self.options.use_local_cache: return False + if not self.cache_path: + return False try: with open(self.cache_path, "r") as f: configs = Parse(f.read(), Prefab.Configs()) @@ -244,15 +249,19 @@ class ConfigClient: logger.info(f"Unlocked config via {source}") def set_cache_path(self): - dir = os.environ.get( - "XDG_CACHE_HOME", os.path.join(os.environ["HOME"], ".cache") - ) - file_name = f"prefab.cache.{self.base_client.options.api_key_id}.json" - self.cache_path = os.path.join(dir, file_name) + home_dir_cache_path = None + home_dir = os.environ.get("HOME") + if home_dir: + home_dir_cache_path = os.path.join(home_dir, ".cache") + cache_path = os.environ.get("XDG_CACHE_HOME", home_dir_cache_path) + if cache_path: + file_name = f"prefab.cache.{self.base_client.options.api_key_id}.json" + self.cache_path = os.path.join(cache_path, file_name) @property def cache_path(self): - os.makedirs(os.path.dirname(self._cache_path), exist_ok=True) + if self._cache_path: + os.makedirs(os.path.dirname(self._cache_path), exist_ok=True) return self._cache_path @cache_path.setter diff --git a/prefab_cloud_python/config_loader.py b/prefab_cloud_python/config_loader.py index 7f942a5..f618e09 100644 --- a/prefab_cloud_python/config_loader.py +++ b/prefab_cloud_python/config_loader.py @@ -12,8 +12,8 @@ class ConfigLoader: self.base_client = base_client self.options = base_client.options self.highwater_mark = 0 - self.classpath_config = self.__load_classpath_config() - self.local_overrides = self.__load_local_overrides() + self.classpath_config = self.__load_classpath_config() or {} + self.local_overrides = self.__load_local_overrides() or {} self.api_config = {} def calc_config(self): @@ -50,8 +50,9 @@ class ConfigLoader: def __load_local_overrides(self): if self.options.has_datafile(): return {} - override_dir = self.options.prefab_config_override_dir - return self.__load_config_from(override_dir) + if self.options.prefab_config_override_dir: + return self.__load_config_from(self.options.prefab_config_override_dir) + return {} def __load_config_from(self, dir): envs = self.options.prefab_envs
prefab-cloud/prefab-cloud-python
746b284749ee40ac8be9a85581f10eb9a913683d
diff --git a/tests/test_config_client.py b/tests/test_config_client.py index b0e5842..3028724 100644 --- a/tests/test_config_client.py +++ b/tests/test_config_client.py @@ -1,5 +1,5 @@ from prefab_cloud_python import Options, Client -from prefab_cloud_python.config_client import MissingDefaultException +from prefab_cloud_python.config_client import MissingDefaultException, ConfigClient import prefab_pb2 as Prefab import pytest import os @@ -8,17 +8,61 @@ from contextlib import contextmanager @contextmanager -def extended_env(new_env_vars): +def extended_env(new_env_vars, deleted_env_vars=[]): old_env = os.environ.copy() os.environ.update(new_env_vars) + for deleted_env_var in deleted_env_vars: + os.environ.pop(deleted_env_var, None) yield os.environ.clear() os.environ.update(old_env) +class ConfigClientFactoryFixture: + def __init__(self): + self.client = None + + def create_config_client(self, options: Options) -> ConfigClient: + self.client = Client(options) + return self.client.config_client() + + def close(self): + if self.client: + self.client.close() + + [email protected] +def config_client_factory(): + factory_fixture = ConfigClientFactoryFixture() + yield factory_fixture + factory_fixture.close() + + [email protected] +def options(): + def options( + on_no_default="RAISE", + x_use_local_cache=True, + prefab_envs=["unit_tests"], + api_key=None, + prefab_datasources="LOCAL_ONLY", + ): + return Options( + api_key=api_key, + prefab_config_classpath_dir="tests", + prefab_envs=prefab_envs, + prefab_datasources=prefab_datasources, + x_use_local_cache=x_use_local_cache, + on_no_default=on_no_default, + collect_sync_interval=None, + ) + + return options + + class TestConfigClient: - def test_get(self): - config_client = self.build_config_client() + def test_get(self, config_client_factory, options): + config_client = config_client_factory.create_config_client(options()) assert config_client.get("sample") == "test sample value" assert config_client.get("sample_int") == 123 @@ -26,13 +70,13 @@ class TestConfigClient: assert config_client.get("sample_bool") assert config_client.get("log-level.app") == Prefab.LogLevel.Value("ERROR") - def test_get_with_default(self): - config_client = self.build_config_client() + def test_get_with_default(self, config_client_factory, options): + config_client = config_client_factory.create_config_client(options()) assert config_client.get("bad key", "default value") == "default value" - def test_get_without_default_raises(self): - config_client = self.build_config_client() + def test_get_without_default_raises(self, config_client_factory, options): + config_client = config_client_factory.create_config_client(options()) with pytest.raises(MissingDefaultException) as exception: config_client.get("bad key") @@ -41,12 +85,16 @@ class TestConfigClient: exception.value ) - def test_get_without_default_returns_none_if_configured(self): - config_client = self.build_config_client("RETURN_NONE") + def test_get_without_default_returns_none_if_configured( + self, config_client_factory, options + ): + config_client = config_client_factory.create_config_client( + options(on_no_default="RETURN_NONE") + ) assert config_client.get("bad key") is None - def test_caching(self): - config_client = self.build_config_client() + def test_caching(self, config_client_factory, options): + config_client = config_client_factory.create_config_client(options()) cached_config = Prefab.Configs( configs=[ Prefab.Config( @@ -72,39 +120,32 @@ class TestConfigClient: config_client.load_cache() assert config_client.get("test") == "test value" - def test_cache_path(self): - options = Options( - api_key="123-API-KEY-SDK", - x_use_local_cache=True, - collect_sync_interval=None, + def test_cache_path(self, config_client_factory, options): + config_client = config_client_factory.create_config_client( + options(api_key="123-API-KEY-SDK", prefab_datasources="ALL") ) - client = Client(options) assert ( - client.config_client().cache_path + config_client.cache_path == f"{os.environ['HOME']}/.cache/prefab.cache.123.json" ) - def test_cache_path_local_only(self): - config_client = self.build_config_client() + def test_cache_path_local_only(self, config_client_factory, options): + config_client = config_client_factory.create_config_client( + options(prefab_envs=[]) + ) assert ( config_client.cache_path == f"{os.environ['HOME']}/.cache/prefab.cache.local.json" ) - def test_cache_path_respects_xdg(self): + def test_cache_path_local_only_with_no_home_dir_or_xdg( + self, config_client_factory, options + ): + with extended_env({}, deleted_env_vars=["HOME"]): + config_client = config_client_factory.create_config_client(options()) + assert config_client.cache_path is None + + def test_cache_path_respects_xdg(self, config_client_factory, options): with extended_env({"XDG_CACHE_HOME": "/tmp"}): - config_client = self.build_config_client() + config_client = config_client_factory.create_config_client(options()) assert config_client.cache_path == "/tmp/prefab.cache.local.json" - - @staticmethod - def build_config_client(on_no_default="RAISE"): - options = Options( - prefab_config_classpath_dir="tests", - prefab_envs="unit_tests", - prefab_datasources="LOCAL_ONLY", - x_use_local_cache=True, - on_no_default=on_no_default, - collect_sync_interval=None, - ) - client = Client(options) - return client.config_client()
Does not work great in AWS lambda (or any HOME-less environment) currently Hey there, we are trying to use prefab-cloud-python in a AWS lambda, and since those usually don't have a HOME directory defined, the following lines throw errors: https://github.com/prefab-cloud/prefab-cloud-python/blob/746b284749ee40ac8be9a85581f10eb9a913683d/prefab_cloud_python/options.py#L59 https://github.com/prefab-cloud/prefab-cloud-python/blob/746b284749ee40ac8be9a85581f10eb9a913683d/prefab_cloud_python/config_client.py#L248 The latter even fails, when an XDG_CACHE_HOME variable is set in the environment since .get() is not used when trying to access HOME. Our workaround is to set a HOME environment variable that points to /tmp for the lambdas, but I'm wondering if relying on HOME to be present in a server environment (serverless or not) is such a great idea?
0.0
746b284749ee40ac8be9a85581f10eb9a913683d
[ "tests/test_config_client.py::TestConfigClient::test_get", "tests/test_config_client.py::TestConfigClient::test_get_with_default", "tests/test_config_client.py::TestConfigClient::test_get_without_default_raises", "tests/test_config_client.py::TestConfigClient::test_get_without_default_returns_none_if_configured", "tests/test_config_client.py::TestConfigClient::test_cache_path_local_only_with_no_home_dir_or_xdg", "tests/test_config_client.py::TestConfigClient::test_cache_path_respects_xdg" ]
[]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2024-02-12 21:25:08+00:00
mit
4,678
pri22296__beautifultable-111
diff --git a/beautifultable/beautifultable.py b/beautifultable/beautifultable.py index 38eca7b..1566643 100644 --- a/beautifultable/beautifultable.py +++ b/beautifultable/beautifultable.py @@ -814,7 +814,10 @@ class BeautifulTable(object): header, self.detect_numerics, self.precision, self.sign.value ).split("\n"): output_str = pre_process( - i, self.detect_numerics, self.precision, self.sign.value, + i, + self.detect_numerics, + self.precision, + self.sign.value, ) max_length = max(max_length, termwidth(output_str)) maxwidths[index] += max_length @@ -952,7 +955,8 @@ class BeautifulTable(object): if termwidth(self.border.left) > 0: if not (self.border.left.isspace() and visible_junc): length = min( - termwidth(self.border.left), termwidth(intersect_left), + termwidth(self.border.left), + termwidth(intersect_left), ) for i in range(length): line[i] = intersect_left[i] if mask[0] else " " diff --git a/beautifultable/helpers.py b/beautifultable/helpers.py index 2171fb1..16f960b 100644 --- a/beautifultable/helpers.py +++ b/beautifultable/helpers.py @@ -239,7 +239,10 @@ class BTRowData(BTBaseRow): for row in map(list, zip_longest(*rows, fillvalue="")): for i in range(len(row)): row[i] = pre_process( - row[i], table.detect_numerics, table.precision, sign.value, + row[i], + table.detect_numerics, + table.precision, + sign.value, ) for row_ in self._clamp_row(row): for i in range(len(table.columns)): @@ -1145,7 +1148,9 @@ class BTColumnCollection(object): self.padding_left = [padding_left] self.padding_right = [padding_right] self.alignment = [alignment] - self._table._data = [BTRowData(self._table, [i]) for i in column] + self._table._data = type(self._table._data)( + self._table, [BTRowData(self._table, [i]) for i in column] + ) else: if (not isinstance(header, basestring)) and (header is not None): raise TypeError( diff --git a/beautifultable/utils.py b/beautifultable/utils.py index 69e4893..06a44eb 100644 --- a/beautifultable/utils.py +++ b/beautifultable/utils.py @@ -83,7 +83,10 @@ def deprecation_message( def deprecated( - deprecated_in, removed_in, replacement=None, details=None, + deprecated_in, + removed_in, + replacement=None, + details=None, ): # pragma: no cover def decorator(f): @functools.wraps(f) @@ -93,20 +96,29 @@ def deprecated( if replacement: details = replacement.__qualname__ details = details.replace( - "BTColumns", "BeautifulTable.columns", + "BTColumns", + "BeautifulTable.columns", ) - details = details.replace("BTRows", "BeautifulTable.rows",) details = details.replace( - "BTColumnHeader", "BeautifulTable.columns.header", + "BTRows", + "BeautifulTable.rows", ) details = details.replace( - "BTRowHeader", "BeautifulTable.rows.header", + "BTColumnHeader", + "BeautifulTable.columns.header", + ) + details = details.replace( + "BTRowHeader", + "BeautifulTable.rows.header", ) details = "Use '{}' instead.".format(details) else: details = "" message = deprecation_message( - f.__qualname__, deprecated_in, removed_in, details, + f.__qualname__, + deprecated_in, + removed_in, + details, ) if replacement: f.__doc__ = "{}\n\n{}".format(replacement.__doc__, message) @@ -119,7 +131,11 @@ def deprecated( def deprecated_param( - deprecated_in, removed_in, old_name, new_name=None, details=None, + deprecated_in, + removed_in, + old_name, + new_name=None, + details=None, ): # pragma: no cover def decorator(f): @functools.wraps(f) @@ -130,7 +146,10 @@ def deprecated_param( "Use '{}' instead.".format(new_name) if new_name else "" ) message = deprecation_message( - old_name, deprecated_in, removed_in, details, + old_name, + deprecated_in, + removed_in, + details, ) if old_name in kwargs: warnings.warn(message, FutureWarning)
pri22296/beautifultable
e16c15890496aa018746c4d333a533f7ba57b6f2
diff --git a/test.py b/test.py index 5671be6..ca6455d 100644 --- a/test.py +++ b/test.py @@ -130,6 +130,26 @@ class TableOperationsTestCase(unittest.TestCase): last_column = self.table.columns[len(self.table.columns) - 1] self.compare_iterable(column, last_column) + def test_append_column_empty_table(self): + self.table = BeautifulTable() + title = "year" + column = ["2010", "2012", "2008", "2010", "2011"] + self.table.columns.append(column, header=title) + string = """+------+ +| year | ++------+ +| 2010 | ++------+ +| 2012 | ++------+ +| 2008 | ++------+ +| 2010 | ++------+ +| 2011 | ++------+""" + self.assertEqual(string, str(self.table)) + def test_insert_column(self): column = ["2010", "2012", "2008", "2010", "2011"] title = "year"
Printing table built using column appending fails in v1.0.0 If a table is constructed by appending columns then attempting to print the table fails. For example: ```python from beautifultable import BeautifulTable tbl = BeautifulTable() tbl.columns.append(["aaa", "bbb", "ccc"], header="One") tbl.columns.append(["ddd", "eee", "fff"], header="Two") tbl.columns.append(["ggg", "hhh", "iii"], header="Three") print(tbl) ``` Produces this error: ``` Traceback (most recent call last): File "append_column.py", line 10, in <module> print(tbl) File "/usr/local/lib/python3.5/dist-packages/beautifultable/beautifultable.py", line 412, in __str__ for line in self._get_string([], append=False): File "/usr/local/lib/python3.5/dist-packages/beautifultable/beautifultable.py", line 1083, in _get_string self.rows.insert(0, self.columns.header) File "/usr/local/lib/python3.5/dist-packages/beautifultable/helpers.py", line 512, in insert self._table._data._insert(index, BTRowData(self._table, row)) AttributeError: 'list' object has no attribute '_insert' ``` Swapping `columns` for `rows` in the above code works (but the table is then rotated by 90 degrees, obv.). Tested under Python 3.7 on FreeBSD 11.4 and Python 3.5 on Debian 9.13 (Raspberry Pi).
0.0
e16c15890496aa018746c4d333a533f7ba57b6f2
[ "test.py::TableOperationsTestCase::test_append_column_empty_table" ]
[ "test.py::TableOperationsTestCase::test_access_column_by_header", "test.py::TableOperationsTestCase::test_access_column_element_by_header", "test.py::TableOperationsTestCase::test_access_column_element_by_index", "test.py::TableOperationsTestCase::test_access_row_by_header", "test.py::TableOperationsTestCase::test_access_row_by_index", "test.py::TableOperationsTestCase::test_access_row_element_by_header", "test.py::TableOperationsTestCase::test_access_row_element_by_index", "test.py::TableOperationsTestCase::test_align_all", "test.py::TableOperationsTestCase::test_ansi_ellipsis", "test.py::TableOperationsTestCase::test_ansi_ellipsis_mb", "test.py::TableOperationsTestCase::test_ansi_sequences", "test.py::TableOperationsTestCase::test_ansi_strip", "test.py::TableOperationsTestCase::test_ansi_strip_mb", "test.py::TableOperationsTestCase::test_ansi_wrap", "test.py::TableOperationsTestCase::test_ansi_wrap_mb", "test.py::TableOperationsTestCase::test_append_column", "test.py::TableOperationsTestCase::test_append_row", "test.py::TableOperationsTestCase::test_column_contains", "test.py::TableOperationsTestCase::test_column_count", "test.py::TableOperationsTestCase::test_column_delitem_int", "test.py::TableOperationsTestCase::test_column_delitem_slice", "test.py::TableOperationsTestCase::test_column_delitem_str", "test.py::TableOperationsTestCase::test_column_getitem_slice", "test.py::TableOperationsTestCase::test_column_header_contains", "test.py::TableOperationsTestCase::test_column_setitem_int", "test.py::TableOperationsTestCase::test_column_setitem_slice", "test.py::TableOperationsTestCase::test_column_setitem_str", "test.py::TableOperationsTestCase::test_csv_export", "test.py::TableOperationsTestCase::test_csv_import", "test.py::TableOperationsTestCase::test_eastasian_characters", "test.py::TableOperationsTestCase::test_empty_header", "test.py::TableOperationsTestCase::test_empty_table_by_column", "test.py::TableOperationsTestCase::test_empty_table_by_row", "test.py::TableOperationsTestCase::test_filter", "test.py::TableOperationsTestCase::test_get_column_header", "test.py::TableOperationsTestCase::test_get_column_index", "test.py::TableOperationsTestCase::test_get_string", "test.py::TableOperationsTestCase::test_insert_column", "test.py::TableOperationsTestCase::test_insert_row", "test.py::TableOperationsTestCase::test_left_align", "test.py::TableOperationsTestCase::test_mixed_align", "test.py::TableOperationsTestCase::test_newline", "test.py::TableOperationsTestCase::test_newline_multiple_columns", "test.py::TableOperationsTestCase::test_pop_column_by_header", "test.py::TableOperationsTestCase::test_pop_column_by_position", "test.py::TableOperationsTestCase::test_pop_row_by_header", "test.py::TableOperationsTestCase::test_pop_row_by_position", "test.py::TableOperationsTestCase::test_right_align", "test.py::TableOperationsTestCase::test_row_contains", "test.py::TableOperationsTestCase::test_row_count", "test.py::TableOperationsTestCase::test_row_delitem_int", "test.py::TableOperationsTestCase::test_row_delitem_slice", "test.py::TableOperationsTestCase::test_row_delitem_str", "test.py::TableOperationsTestCase::test_row_getitem_slice", "test.py::TableOperationsTestCase::test_row_header_contains", "test.py::TableOperationsTestCase::test_row_setitem_int", "test.py::TableOperationsTestCase::test_row_setitem_slice", "test.py::TableOperationsTestCase::test_row_setitem_str", "test.py::TableOperationsTestCase::test_sign_plus", "test.py::TableOperationsTestCase::test_sort_by_callable", "test.py::TableOperationsTestCase::test_sort_by_header", "test.py::TableOperationsTestCase::test_sort_by_index", "test.py::TableOperationsTestCase::test_sort_by_index_reversed", "test.py::TableOperationsTestCase::test_sort_raises_exception", "test.py::TableOperationsTestCase::test_stream", "test.py::TableOperationsTestCase::test_table_auto_width", "test.py::TableOperationsTestCase::test_table_width_zero", "test.py::TableOperationsTestCase::test_update_column_by_header", "test.py::TableOperationsTestCase::test_update_column_by_index", "test.py::TableOperationsTestCase::test_update_column_slice", "test.py::TableOperationsTestCase::test_update_row_by_header", "test.py::TableOperationsTestCase::test_update_row_by_index", "test.py::TableOperationsTestCase::test_update_row_slice", "test.py::TableOperationsTestCase::test_wep_ellipsis", "test.py::TableOperationsTestCase::test_wep_strip", "test.py::TableOperationsTestCase::test_wep_wrap" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2020-12-20 08:32:24+00:00
mit
4,679
pri22296__beautifultable-64
diff --git a/.gitignore b/.gitignore index 4527dcd..e70f354 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dist/ build/ .tox/ *.pyc +.coverage diff --git a/README.rst b/README.rst index 16aadd1..c26bea2 100644 --- a/README.rst +++ b/README.rst @@ -133,6 +133,8 @@ Unreleased * Dropped support for Python 3.3 * Added support for streaming tables using a generator for cases where data retrieval is slow +* Alignment, padding, width can now be set for all columns using a simplified syntax like + ``table.column_alignments = beautifultable.ALIGN_LEFT`` ========== v0.7.0 diff --git a/beautifultable/beautifultable.py b/beautifultable/beautifultable.py index ae4041f..3f54c51 100644 --- a/beautifultable/beautifultable.py +++ b/beautifultable/beautifultable.py @@ -332,6 +332,8 @@ class BeautifulTable(object): @column_widths.setter def column_widths(self, value): + if isinstance(value, int): + value = [value] * self._column_count width = self._validate_row(value) self._column_widths = PositiveIntegerMetaData(self, width) @@ -366,6 +368,8 @@ class BeautifulTable(object): @column_alignments.setter def column_alignments(self, value): + if isinstance(value, enums.Alignment): + value = [value] * self._column_count alignment = self._validate_row(value) self._column_alignments = AlignmentMetaData(self, alignment) @@ -380,6 +384,8 @@ class BeautifulTable(object): @left_padding_widths.setter def left_padding_widths(self, value): + if isinstance(value, int): + value = [value] * self._column_count pad_width = self._validate_row(value) self._left_padding_widths = PositiveIntegerMetaData(self, pad_width) @@ -394,6 +400,8 @@ class BeautifulTable(object): @right_padding_widths.setter def right_padding_widths(self, value): + if isinstance(value, int): + value = [value] * self._column_count pad_width = self._validate_row(value) self._right_padding_widths = PositiveIntegerMetaData(self, pad_width)
pri22296/beautifultable
d5a4c55cff51809bf020ed1cc56c377b48e30ff3
diff --git a/test.py b/test.py index c0fa342..8deb0a5 100644 --- a/test.py +++ b/test.py @@ -245,6 +245,23 @@ class TableOperationsTestCase(unittest.TestCase): | Sophia | 2 | girl | +----------+------+--------+ | Michael | 3 | boy | ++----------+------+--------+""" + self.assertEqual(string, self.table.get_string()) + + def test_align_all(self): + self.table.column_alignments = self.table.ALIGN_LEFT + string = """+----------+------+--------+ +| name | rank | gender | ++----------+------+--------+ +| Jacob | 1 | boy | ++----------+------+--------+ +| Isabella | 1 | girl | ++----------+------+--------+ +| Ethan | 2 | boy | ++----------+------+--------+ +| Sophia | 2 | girl | ++----------+------+--------+ +| Michael | 3 | boy | +----------+------+--------+""" self.assertEqual(string, self.table.get_string())
Allow setting alignment, etc for all columns more easily The following syntax could be used to align all columns with a simple statement. ``` table.column_alignments = beautifultable.ALIGN_LEFT ```
0.0
d5a4c55cff51809bf020ed1cc56c377b48e30ff3
[ "test.py::TableOperationsTestCase::test_align_all" ]
[ "test.py::TableOperationsTestCase::test_access_column_by_header", "test.py::TableOperationsTestCase::test_access_row_by_index", "test.py::TableOperationsTestCase::test_access_row_element_by_header", "test.py::TableOperationsTestCase::test_access_row_element_by_index", "test.py::TableOperationsTestCase::test_ansi_ellipsis", "test.py::TableOperationsTestCase::test_ansi_sequences", "test.py::TableOperationsTestCase::test_ansi_strip", "test.py::TableOperationsTestCase::test_ansi_wrap", "test.py::TableOperationsTestCase::test_append_column", "test.py::TableOperationsTestCase::test_append_row", "test.py::TableOperationsTestCase::test_column_count", "test.py::TableOperationsTestCase::test_contains", "test.py::TableOperationsTestCase::test_delitem_int", "test.py::TableOperationsTestCase::test_delitem_slice", "test.py::TableOperationsTestCase::test_delitem_str", "test.py::TableOperationsTestCase::test_empty_header", "test.py::TableOperationsTestCase::test_empty_table_by_column", "test.py::TableOperationsTestCase::test_empty_table_by_row", "test.py::TableOperationsTestCase::test_get_column_header", "test.py::TableOperationsTestCase::test_get_column_index", "test.py::TableOperationsTestCase::test_get_string", "test.py::TableOperationsTestCase::test_getitem_slice", "test.py::TableOperationsTestCase::test_insert_column", "test.py::TableOperationsTestCase::test_insert_row", "test.py::TableOperationsTestCase::test_left_align", "test.py::TableOperationsTestCase::test_mixed_align", "test.py::TableOperationsTestCase::test_newline", "test.py::TableOperationsTestCase::test_newline_multiple_columns", "test.py::TableOperationsTestCase::test_pop_column_by_header", "test.py::TableOperationsTestCase::test_pop_column_by_position", "test.py::TableOperationsTestCase::test_pop_row", "test.py::TableOperationsTestCase::test_right_align", "test.py::TableOperationsTestCase::test_row_count", "test.py::TableOperationsTestCase::test_serialno", "test.py::TableOperationsTestCase::test_setitem_int", "test.py::TableOperationsTestCase::test_setitem_slice", "test.py::TableOperationsTestCase::test_setitem_str", "test.py::TableOperationsTestCase::test_signmode_plus", "test.py::TableOperationsTestCase::test_table_auto_width", "test.py::TableOperationsTestCase::test_table_width_zero", "test.py::TableOperationsTestCase::test_update_column", "test.py::TableOperationsTestCase::test_update_row", "test.py::TableOperationsTestCase::test_update_row_slice", "test.py::TableOperationsTestCase::test_wep_ellipsis", "test.py::TableOperationsTestCase::test_wep_strip", "test.py::TableOperationsTestCase::test_wep_wrap" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2019-06-23 05:46:47+00:00
mit
4,680
pri22296__beautifultable-77
diff --git a/.gitignore b/.gitignore index e70f354..87e4a82 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build/ .tox/ *.pyc .coverage +.vscode/ diff --git a/beautifultable/beautifultable.py b/beautifultable/beautifultable.py index dde020c..90ff9bd 100644 --- a/beautifultable/beautifultable.py +++ b/beautifultable/beautifultable.py @@ -800,12 +800,16 @@ class BeautifulTable(object): If `True` then table is sorted as if each comparison was reversed. """ if isinstance(key, int): - index = key + key = operator.itemgetter(key) elif isinstance(key, basestring): - index = self.get_column_index(key) + key = operator.itemgetter(self.get_column_index(key)) + elif callable(key): + pass else: - raise TypeError("'key' must either be 'int' or 'str'") - self._table.sort(key=operator.itemgetter(index), reverse=reverse) + raise TypeError( + "'key' must either be 'int' or 'str' or a 'callable'" + ) + self._table.sort(key=key, reverse=reverse) def copy(self): """Return a shallow copy of the table. @@ -1432,7 +1436,7 @@ class BeautifulTable(object): return "\n".join(string_) - def to_csv(self, file_name, delimiter=','): + def to_csv(self, file_name, delimiter=","): """Export table to CSV format. Parameters @@ -1446,22 +1450,22 @@ class BeautifulTable(object): if not isinstance(file_name, str): raise ValueError( - ( - "Expected 'file_name' to be string, got {}" - ).format(type(file_name).__name__) + ("Expected 'file_name' to be string, got {}").format( + type(file_name).__name__ + ) ) try: - with open(file_name, mode='wt', newline='') as csv_file: - csv_writer = csv.writer(csv_file, - delimiter=delimiter, - quoting=csv.QUOTE_MINIMAL) + with open(file_name, mode="wt", newline="") as csv_file: + csv_writer = csv.writer( + csv_file, delimiter=delimiter, quoting=csv.QUOTE_MINIMAL + ) csv_writer.writerow(self.column_headers) # write header csv_writer.writerows(self._table) # write table except OSError: raise - def from_csv(self, file_name, delimiter=',', header_exists=True): + def from_csv(self, file_name, delimiter=",", header_exists=True): """Create table from CSV file. Parameters @@ -1483,13 +1487,13 @@ class BeautifulTable(object): if not isinstance(file_name, str): raise ValueError( - ( - "Expected 'file_name' to be string, got {}" - ).format(type(file_name).__name__) + ("Expected 'file_name' to be string, got {}").format( + type(file_name).__name__ + ) ) try: - with open(file_name, mode='rt', newline='') as csv_file: + with open(file_name, mode="rt", newline="") as csv_file: csv_file = csv.reader(csv_file, delimiter=delimiter) if header_exists:
pri22296/beautifultable
ed329595a1fd0dfaaf4d8d6ff75a36e514b07331
diff --git a/test.py b/test.py index 0ad9017..2e8699f 100644 --- a/test.py +++ b/test.py @@ -25,6 +25,8 @@ class TableOperationsTestCase(unittest.TestCase): for item1, item2 in zip(iterable1, iterable2): self.assertEqual(item1, item2) + # Test for table operations + def test_filter(self): new_table = self.table.filter(lambda x: x["rank"] > 1) self.assertEqual(len(self.table), 5) @@ -36,6 +38,58 @@ class TableOperationsTestCase(unittest.TestCase): for row_t, row in zip(new_table, rows): self.compare_iterable(row_t, row) + def test_sort_by_index(self): + self.table.sort(0) + rows = [ + ["Ethan", 2, "boy"], + ["Isabella", 1, "girl"], + ["Jacob", 1, "boy"], + ["Michael", 3, "boy"], + ["Sophia", 2, "girl"], + ] + for row_t, row in zip(self.table, rows): + self.compare_iterable(row_t, row) + + def test_sort_by_index_reversed(self): + self.table.sort(0, reverse=True) + rows = [ + ["Ethan", 2, "boy"], + ["Isabella", 1, "girl"], + ["Jacob", 1, "boy"], + ["Michael", 3, "boy"], + ["Sophia", 2, "girl"], + ] + for row_t, row in zip(self.table, reversed(rows)): + self.compare_iterable(row_t, row) + + def test_sort_by_header(self): + self.table.sort("name") + rows = [ + ["Ethan", 2, "boy"], + ["Isabella", 1, "girl"], + ["Jacob", 1, "boy"], + ["Michael", 3, "boy"], + ["Sophia", 2, "girl"], + ] + for row_t, row in zip(self.table, rows): + self.compare_iterable(row_t, row) + + def test_sort_by_callable(self): + self.table.sort(lambda x: (x[1], x[0])) + rows = [ + ["Isabella", 1, "girl"], + ["Jacob", 1, "boy"], + ["Ethan", 2, "boy"], + ["Sophia", 2, "girl"], + ["Michael", 3, "boy"], + ] + for row_t, row in zip(self.table, rows): + self.compare_iterable(row_t, row) + + def test_sort_raises_exception(self): + with self.assertRaises(TypeError): + self.table.sort(None) + # Tests for column operations def test_column_count(self): @@ -530,26 +584,26 @@ class TableOperationsTestCase(unittest.TestCase): def test_csv_export(self): # Create csv files in path. - self.table.to_csv('beautiful_table.csv') - self.table.to_csv('./docs/beautiful_table.csv') + self.table.to_csv("beautiful_table.csv") + self.table.to_csv("./docs/beautiful_table.csv") with self.assertRaises(ValueError): self.table.to_csv(1) # Check if csv files exist. - self.assertTrue(os.path.exists('beautiful_table.csv')) - self.assertTrue(os.path.exists('./docs/beautiful_table.csv')) + self.assertTrue(os.path.exists("beautiful_table.csv")) + self.assertTrue(os.path.exists("./docs/beautiful_table.csv")) # Teardown step. - os.remove('beautiful_table.csv') - os.remove('./docs/beautiful_table.csv') + os.remove("beautiful_table.csv") + os.remove("./docs/beautiful_table.csv") def test_csv_import(self): # Export table as CSV file and import it back. - self.table.to_csv('beautiful_table.csv') + self.table.to_csv("beautiful_table.csv") test_table = BeautifulTable() - test_table.from_csv('beautiful_table.csv') + test_table.from_csv("beautiful_table.csv") with self.assertRaises(ValueError): self.table.from_csv(1) @@ -561,11 +615,11 @@ class TableOperationsTestCase(unittest.TestCase): # self.assertEqual(self.table[index], test_table[index]) test_table = BeautifulTable() - test_table.from_csv('beautiful_table.csv', header_exists=False) + test_table.from_csv("beautiful_table.csv", header_exists=False) self.assertEqual(len(self.table), len(test_table) - 1) # Teardown step. - os.remove('beautiful_table.csv') + os.remove("beautiful_table.csv") if __name__ == "__main__":
Allow sort based on an arbitrary callable Currently we can sort the table based on a column. But we should allow the use of any callable as a key function like the sort method of list.
0.0
ed329595a1fd0dfaaf4d8d6ff75a36e514b07331
[ "test.py::TableOperationsTestCase::test_sort_by_callable" ]
[ "test.py::TableOperationsTestCase::test_access_column_by_header", "test.py::TableOperationsTestCase::test_access_row_by_index", "test.py::TableOperationsTestCase::test_access_row_element_by_header", "test.py::TableOperationsTestCase::test_access_row_element_by_index", "test.py::TableOperationsTestCase::test_align_all", "test.py::TableOperationsTestCase::test_ansi_ellipsis", "test.py::TableOperationsTestCase::test_ansi_sequences", "test.py::TableOperationsTestCase::test_ansi_strip", "test.py::TableOperationsTestCase::test_ansi_wrap", "test.py::TableOperationsTestCase::test_append_column", "test.py::TableOperationsTestCase::test_append_row", "test.py::TableOperationsTestCase::test_column_count", "test.py::TableOperationsTestCase::test_contains", "test.py::TableOperationsTestCase::test_csv_export", "test.py::TableOperationsTestCase::test_csv_import", "test.py::TableOperationsTestCase::test_delitem_int", "test.py::TableOperationsTestCase::test_delitem_slice", "test.py::TableOperationsTestCase::test_delitem_str", "test.py::TableOperationsTestCase::test_empty_header", "test.py::TableOperationsTestCase::test_empty_table_by_column", "test.py::TableOperationsTestCase::test_empty_table_by_row", "test.py::TableOperationsTestCase::test_filter", "test.py::TableOperationsTestCase::test_get_column_header", "test.py::TableOperationsTestCase::test_get_column_index", "test.py::TableOperationsTestCase::test_get_string", "test.py::TableOperationsTestCase::test_getitem_slice", "test.py::TableOperationsTestCase::test_insert_column", "test.py::TableOperationsTestCase::test_insert_row", "test.py::TableOperationsTestCase::test_left_align", "test.py::TableOperationsTestCase::test_mixed_align", "test.py::TableOperationsTestCase::test_newline", "test.py::TableOperationsTestCase::test_newline_multiple_columns", "test.py::TableOperationsTestCase::test_pop_column_by_header", "test.py::TableOperationsTestCase::test_pop_column_by_position", "test.py::TableOperationsTestCase::test_pop_row", "test.py::TableOperationsTestCase::test_right_align", "test.py::TableOperationsTestCase::test_row_count", "test.py::TableOperationsTestCase::test_serialno", "test.py::TableOperationsTestCase::test_setitem_int", "test.py::TableOperationsTestCase::test_setitem_slice", "test.py::TableOperationsTestCase::test_setitem_str", "test.py::TableOperationsTestCase::test_signmode_plus", "test.py::TableOperationsTestCase::test_sort_by_header", "test.py::TableOperationsTestCase::test_sort_by_index", "test.py::TableOperationsTestCase::test_sort_by_index_reversed", "test.py::TableOperationsTestCase::test_sort_raises_exception", "test.py::TableOperationsTestCase::test_table_auto_width", "test.py::TableOperationsTestCase::test_table_width_zero", "test.py::TableOperationsTestCase::test_update_column", "test.py::TableOperationsTestCase::test_update_row", "test.py::TableOperationsTestCase::test_update_row_slice", "test.py::TableOperationsTestCase::test_wep_ellipsis", "test.py::TableOperationsTestCase::test_wep_strip", "test.py::TableOperationsTestCase::test_wep_wrap" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_many_modified_files", "has_many_hunks", "has_pytest_match_arg" ], "has_test_patch": true, "is_lite": false }
2019-09-14 09:06:23+00:00
mit
4,681
project-receptor__receptor-satellite-5
diff --git a/receptor_satellite/response/messages.py b/receptor_satellite/response/messages.py index 23ee860..b16de05 100644 --- a/receptor_satellite/response/messages.py +++ b/receptor_satellite/response/messages.py @@ -30,12 +30,21 @@ def playbook_run_cancel_ack(playbook_run_id, status): } -def playbook_run_finished(host, playbook_run_id, result=RESULT_SUCCESS): +def playbook_run_finished( + host, + playbook_run_id, + result=RESULT_SUCCESS, + connection_error=False, + execution_code=0, +): return { + "version": 2, "type": "playbook_run_finished", "playbook_run_id": playbook_run_id, "host": host, "status": result, + "connection_code": 1 if connection_error else 0, + "execution_code": None if connection_error else execution_code, } diff --git a/receptor_satellite/response/response_queue.py b/receptor_satellite/response/response_queue.py index 4cf0f45..dc5dab0 100644 --- a/receptor_satellite/response/response_queue.py +++ b/receptor_satellite/response/response_queue.py @@ -15,9 +15,18 @@ class ResponseQueue: ) def playbook_run_finished( - self, host, playbook_run_id, result=constants.RESULT_SUCCESS + self, + host, + playbook_run_id, + result=constants.RESULT_SUCCESS, + connection_error=False, + exit_code=0, ): - self.queue.put(messages.playbook_run_finished(host, playbook_run_id, result)) + self.queue.put( + messages.playbook_run_finished( + host, playbook_run_id, result, connection_error, exit_code + ) + ) def playbook_run_completed( self, playbook_run_id, status, connection_error=None, infrastructure_error=None diff --git a/receptor_satellite/worker.py b/receptor_satellite/worker.py index e16b45b..5140766 100644 --- a/receptor_satellite/worker.py +++ b/receptor_satellite/worker.py @@ -9,7 +9,8 @@ import receptor_satellite.response.constants as constants from .run_monitor import run_monitor # EXCEPTION means failure between capsule and the target host -EXIT_STATUS_RE = re.compile(r"Exit status: ([0-9]+|EXCEPTION)", re.MULTILINE) +EXIT_STATUS_RE = re.compile(r"Exit status: (([0-9]+)|EXCEPTION)", re.MULTILINE) +UNREACHABLE_RE = re.compile(r"unreachable=[1-9][0-9]*") def receptor_export(func): @@ -93,6 +94,8 @@ class Host: self.sequence = 0 self.since = None if run.config.text_update_full else 0.0 self.result = None + self.last_recap_line = "" + self.host_recap_re = re.compile(f"^.*{name}.*ok=[0-9]+") def mark_as_failed(self, message): queue = self.run.queue @@ -119,16 +122,32 @@ class Host: self.name, self.run.playbook_run_id, last_output, self.sequence ) self.sequence += 1 + + possible_recaps = list( + filter( + lambda x: re.match(self.host_recap_re, x), last_output.split("\n") + ) + ) + if len(possible_recaps) > 0: + self.last_recap_line = possible_recaps.pop() + if body["complete"]: + connection_error = re.search(UNREACHABLE_RE, self.last_recap_line) result = constants.HOST_RESULT_FAILURE matches = re.findall(EXIT_STATUS_RE, last_output) + exit_code = None # This means the job was already running on the host if matches: - # If exitcode is 0 - if matches[0] == "0": - result = constants.HOST_RESULT_SUCCESS - elif self.run.cancelled: - result = constants.HOST_RESULT_CANCEL + code = matches[0][1] + # If there was an exit code + if code != "": + exit_code = int(code) + if exit_code == 0: + result = constants.HOST_RESULT_SUCCESS + elif self.run.cancelled: + result = constants.HOST_RESULT_CANCEL + else: + result = constants.HOST_RESULT_FAILURE elif self.run.cancelled: result = constants.HOST_RESULT_CANCEL else: @@ -139,6 +158,8 @@ class Host: constants.HOST_RESULT_FAILURE if result == constants.HOST_RESULT_INFRA_FAILURE else result, + connection_error or result == constants.HOST_RESULT_INFRA_FAILURE, + exit_code, ) self.result = result break diff --git a/setup.cfg b/setup.cfg index 849e449..3c1f6ae 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,6 +21,7 @@ ignore=E201,E203,E221,E225,E231,E241,E251,E261,E265,E303,W291,W391,W293,E731,F40 exclude=.tox,venv,awx/lib/site-packages,awx/plugins/inventory,awx/ui,awx/api/urls.py,awx/main/migrations,awx/main/south_migrations,awx/main/tests/data,node_modules/,awx/projects/,tools/docker,awx/settings/local_*.py,installer/openshift/settings.py,build/,installer/ per-file-ignores = tests/constants.py:E501 + tests/test_run.py:E501 [metadata] license_file=LICENSE.md
project-receptor/receptor-satellite
9c636515c06c01246641abbf4e786888d050fa9b
diff --git a/tests/test_response_queue.py b/tests/test_response_queue.py index 170a8dc..d53ddef 100644 --- a/tests/test_response_queue.py +++ b/tests/test_response_queue.py @@ -13,7 +13,10 @@ PLAYBOOK_RUN_COMPLETED_TEST_CASES = [ ), ( ("some-uuid", constants.RESULT_FAILURE, None, None), - messages.playbook_run_completed("some-uuid", constants.RESULT_FAILURE,), + messages.playbook_run_completed( + "some-uuid", + constants.RESULT_FAILURE, + ), ), ( ("some-uuid", constants.RESULT_CANCEL, None, None), diff --git a/tests/test_run.py b/tests/test_run.py index 329fcb1..cfa658b 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -125,7 +125,11 @@ def poll_with_retries_scenario(request, base_scenario): @pytest.mark.asyncio async def test_poll_with_retries(poll_with_retries_scenario): - (queue, host, param,) = poll_with_retries_scenario + ( + queue, + host, + param, + ) = poll_with_retries_scenario satellite_api = host.run.satellite_api satellite_api.responses = [ param.api_output for _x in range(len(param.api_requests)) @@ -211,7 +215,7 @@ POLLING_LOOP_TEST_CASES = [ queue_messages=[ messages.playbook_run_update("host1", "play_id", "Exit status: 123", 0), messages.playbook_run_finished( - "host1", "play_id", constants.RESULT_FAILURE + "host1", "play_id", constants.RESULT_FAILURE, False, 123 ), ], ), @@ -226,7 +230,9 @@ POLLING_LOOP_TEST_CASES = [ api_requests=[("output", (None, 1, None))], queue_messages=[ messages.playbook_run_update("host1", "play_id", "Exit status: 123", 0), - messages.playbook_run_finished("host1", "play_id", constants.RESULT_CANCEL), + messages.playbook_run_finished( + "host1", "play_id", constants.RESULT_CANCEL, False, 123 + ), ], ), ] @@ -243,7 +249,11 @@ def polling_loop_scenario(request, base_scenario): @pytest.mark.asyncio async def test_polling_loop(polling_loop_scenario): - (queue, host, param,) = polling_loop_scenario + ( + queue, + host, + param, + ) = polling_loop_scenario satellite_api = host.run.satellite_api satellite_api.responses = [ param.api_output for _x in range(len(param.api_requests)) @@ -331,7 +341,10 @@ START_TEST_CASES = [ messages.playbook_run_finished( "host1", "play_id", constants.RESULT_SUCCESS ), - messages.playbook_run_completed("play_id", constants.RESULT_SUCCESS,), + messages.playbook_run_completed( + "play_id", + constants.RESULT_SUCCESS, + ), ], FakeLogger() .info("Playbook run play_id running as job invocation 123") @@ -369,7 +382,7 @@ START_TEST_CASES = [ 0, ), messages.playbook_run_finished( - "host1", "play_id", constants.HOST_RESULT_FAILURE + "host1", "play_id", constants.HOST_RESULT_FAILURE, True ), messages.playbook_run_completed( "play_id", @@ -390,16 +403,53 @@ START_TEST_CASES = [ error=None, ), dict( + error=None, body={ + "complete": True, "output": [ { - "output": "Error initializing command: Net::SSH::AuthenticationFailed - Authentication failed for user [email protected]\n" # noqa: E501 + "output": "\u001b[0;34mUsing /etc/ansible/ansible.cfg as config file\u001b[0m\n", + "output_type": "stdout", + "timestamp": 1600350676.69755, + }, + { + "output": "\n", + "output_type": "stdout", + "timestamp": 1600350677.70155, + }, + { + "output": "\r\nPLAY [all] *********************************************************************\n", + "output_type": "stdout", + "timestamp": 1600350677.70175, + }, + { + "output": "\r\nTASK [Gathering Facts] *********************************************************\n", + "output_type": "stdout", + "timestamp": 1600350677.70195, + }, + { + "output": "\n", + "output_type": "stdout", + "timestamp": 1600350677.70212, + }, + { + "output": '\u001b[1;31mfatal: [host1]: UNREACHABLE! => {"changed": false, "msg": "Invalid/incorrect password: Permission denied, please try again.\\r\\nPermission denied, please try again.\\r\\nReceived disconnect from 10.110.156.47 port 22:2: Too many authentication failures\\r\\nDisconnected from 10.110.156.47 port 22", "unreachable": true}\u001b[0m\n', + "output_type": "stdout", + "timestamp": 1600350684.0395, + }, + { + "output": "PLAY RECAP *********************************************************************\n\u001b[0;31mhost1\u001b[0m : ok=0 changed=0 \u001b[1;31munreachable=1 \u001b[0m failed=0 skipped=0 rescued=0 ignored=0 ", + "output_type": "stdout", + "timestamp": 1600350687.1491, + }, + { + "output": "Exit status: 1", + "output_type": "stdout", + "timestamp": 1600350688.1491, }, - {"output": "Exit status: EXCEPTION"}, ], - "complete": True, + "refresh": False, }, - error=None, ), ], [ @@ -411,13 +461,16 @@ START_TEST_CASES = [ messages.playbook_run_update( "host1", "play_id", - "Error initializing command: Net::SSH::AuthenticationFailed - Authentication failed for user [email protected]\nExit status: EXCEPTION", # noqa: E501 + '\x1b[0;34mUsing /etc/ansible/ansible.cfg as config file\x1b[0m\n\n\r\nPLAY [all] *********************************************************************\n\r\nTASK [Gathering Facts] *********************************************************\n\n\x1b[1;31mfatal: [host1]: UNREACHABLE! => {"changed": false, "msg": "Invalid/incorrect password: Permission denied, please try again.\\r\\nPermission denied, please try again.\\r\\nReceived disconnect from 10.110.156.47 port 22:2: Too many authentication failures\\r\\nDisconnected from 10.110.156.47 port 22", "unreachable": true}\x1b[0m\nPLAY RECAP *********************************************************************\n\x1b[0;31mhost1\x1b[0m : ok=0 changed=0 \x1b[1;31munreachable=1 \x1b[0m failed=0 skipped=0 rescued=0 ignored=0 Exit status: 1', 0, ), messages.playbook_run_finished( - "host1", "play_id", constants.HOST_RESULT_FAILURE + "host1", "play_id", constants.HOST_RESULT_FAILURE, True + ), + messages.playbook_run_completed( + "play_id", + constants.RESULT_FAILURE, ), - messages.playbook_run_completed("play_id", constants.RESULT_FAILURE,), ], FakeLogger() .info("Playbook run play_id running as job invocation 123")
Implement v2 playbook_run_finished [response] run playbook finished This message is sent for each host individually when a Playbook execution on a given host finishes. ``` { "type": "playbook_run_finished", // id of the remediation execution "playbook_run_id": "a30f1d7c-ba75-465b-a217-63f3f553836f", "host": "01.example.com", "status": "success" || "failure" || "canceled", "version": 2, "connection_code": 0 (success) || 1 (error), "execution_code": 0 (success) || number (return code from ansible) || null (in case connection code is 1) } ``` [response] run playbook finished ad1 https://bugzilla.redhat.com/show_bug.cgi?id=1833039 RHCLOUD-5370 There are certain failure situation that we know may happen (e.g. "This host is not known by Satellite"). Currently there is no way for sat-receptor to indicate these other than adding the error message into the "console" text field. We should introduce code/error field with well-defined values so that Remediations can understand the semantics of what the problem was without having to parse the text field. Extend playbook_run_finished We can add a second type of failure: - Satellite can’t reach host - Satellite connected, but the run failed (e.g. problem in ansible playbook)
0.0
9c636515c06c01246641abbf4e786888d050fa9b
[ "tests/test_response_queue.py::test_playbook_run_completed[playbook_run_completed_scenario0]", "tests/test_response_queue.py::test_playbook_run_completed[playbook_run_completed_scenario1]", "tests/test_response_queue.py::test_playbook_run_completed[playbook_run_completed_scenario2]", "tests/test_response_queue.py::test_playbook_run_completed[playbook_run_completed_scenario3]", "tests/test_response_queue.py::test_playbook_run_completed[playbook_run_completed_scenario4]", "tests/test_run.py::test_mark_as_failed", "tests/test_run.py::test_poll_with_retries[poll_with_retries_scenario0]", "tests/test_run.py::test_poll_with_retries[poll_with_retries_scenario1]", "tests/test_run.py::test_polling_loop[polling_loop_scenario0]", "tests/test_run.py::test_polling_loop[polling_loop_scenario1]", "tests/test_run.py::test_polling_loop[polling_loop_scenario2]", "tests/test_run.py::test_polling_loop[polling_loop_scenario3]", "tests/test_run.py::test_polling_loop[polling_loop_scenario4]", "tests/test_run.py::test_polling_loop[polling_loop_scenario5]", "tests/test_run.py::test_hostname_sanity", "tests/test_run.py::test_start[start_scenario0]", "tests/test_run.py::test_start[start_scenario1]", "tests/test_run.py::test_start[start_scenario2]", "tests/test_run.py::test_start[start_scenario3]" ]
[]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2020-09-18 10:31:11+00:00
apache-2.0
4,682
projectmesa__mesa-1001
diff --git a/HISTORY.rst b/HISTORY.rst index 315c12f..f67babe 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,14 @@ Release History --------------- + +0.8.9 (TBD) Oro Valley ++++++++++++++++++++++++++++++++++++++++++++ + +*Note: Master branch was renamed to Main on 03/13/2021* + + + 0.8.8 (2020-11-27) Nogales +++++++++++++++++++++++++++++++++++++++++++ diff --git a/mesa/space.py b/mesa/space.py index 37716c5..2544d75 100644 --- a/mesa/space.py +++ b/mesa/space.py @@ -950,6 +950,12 @@ class NetworkGrid: self.G.nodes[node_id]["agent"].remove(agent) + def remove_agent(self, agent: Agent) -> None: + """ Remove the agent from the network and set its pos variable to None. """ + pos = agent.pos + self._remove_agent(agent, pos) + agent.pos = None + def is_cell_empty(self, node_id: int) -> bool: """ Returns a bool of the contents of a cell. """ return not self.G.nodes[node_id]["agent"]
projectmesa/mesa
b87ab898847dbf9124ae50c369a5ee00b849f30a
diff --git a/tests/test_space.py b/tests/test_space.py index d9f1017..38520b3 100644 --- a/tests/test_space.py +++ b/tests/test_space.py @@ -357,6 +357,15 @@ class TestSingleNetworkGrid(unittest.TestCase): assert _agent not in self.space.G.nodes[initial_pos]["agent"] assert _agent in self.space.G.nodes[final_pos]["agent"] + def test_remove_agent(self): + for i, pos in enumerate(TEST_AGENTS_NETWORK_SINGLE): + a = self.agents[i] + assert a.pos == pos + assert a in self.space.G.nodes[pos]["agent"] + self.space.remove_agent(a) + assert a.pos is None + assert a not in self.space.G.nodes[pos]["agent"] + def test_is_cell_empty(self): assert not self.space.is_cell_empty(0) assert self.space.is_cell_empty(TestSingleNetworkGrid.GRAPH_SIZE - 1)
No public version of NetworkGrid._remove_agent, though code exists Currently it is not possible to remove an Agent from a NetworkGrid using a **public** function. Currently, you can do the following: ```python ... model.grid = NetworkGrid(G) ... a = Agent(...) model.grid._remove_agent(a, a.pos) ... ``` But this function is a private function, therefore it isn't shown in documentation or in your editor. I'd like to be able to remove agents like with the other space modules. **Describe the solution you'd like** I'd like a similar solution as used for the other space modules: Solution in space.Grid: ```python def remove_agent(self, agent: Agent) -> None: # solution in space.Grid """ Remove the agent from the grid and set its pos variable to None. """ pos = agent.pos self._remove_agent(pos, agent) agent.pos = None ``` Solution for NetworkGrid: ```python def remove_agent(self, agent: Agent) -> None: # New solution """ Remove the agent from the network and set its pos variable to None. """ pos = agent.pos self._remove_agent(agent, pos) agent.pos = None ``` **Additional context** The _remove_agent function in NetworkGrid ```python def _remove_agent(self, agent: Agent, node_id: int) -> None: """ Remove an agent from a node. """ self.G.nodes[node_id]["agent"].remove(agent) ```
0.0
b87ab898847dbf9124ae50c369a5ee00b849f30a
[ "tests/test_space.py::TestSingleNetworkGrid::test_remove_agent" ]
[ "tests/test_space.py::TestSpaceToroidal::test_agent_matching", "tests/test_space.py::TestSpaceToroidal::test_agent_positions", "tests/test_space.py::TestSpaceToroidal::test_bounds", "tests/test_space.py::TestSpaceToroidal::test_distance_calculations", "tests/test_space.py::TestSpaceToroidal::test_heading", "tests/test_space.py::TestSpaceToroidal::test_neighborhood_retrieval", "tests/test_space.py::TestSpaceNonToroidal::test_agent_matching", "tests/test_space.py::TestSpaceNonToroidal::test_agent_positions", "tests/test_space.py::TestSpaceNonToroidal::test_bounds", "tests/test_space.py::TestSpaceNonToroidal::test_distance_calculations", "tests/test_space.py::TestSpaceNonToroidal::test_heading", "tests/test_space.py::TestSpaceNonToroidal::test_neighborhood_retrieval", "tests/test_space.py::TestSpaceAgentMapping::test_remove_first", "tests/test_space.py::TestSpaceAgentMapping::test_remove_last", "tests/test_space.py::TestSpaceAgentMapping::test_remove_middle", "tests/test_space.py::TestSingleGrid::test_agent_positions", "tests/test_space.py::TestSingleGrid::test_empty_cells", "tests/test_space.py::TestSingleGrid::test_remove_agent", "tests/test_space.py::TestSingleNetworkGrid::test_agent_positions", "tests/test_space.py::TestSingleNetworkGrid::test_get_all_cell_contents", "tests/test_space.py::TestSingleNetworkGrid::test_get_cell_list_contents", "tests/test_space.py::TestSingleNetworkGrid::test_get_neighbors", "tests/test_space.py::TestSingleNetworkGrid::test_is_cell_empty", "tests/test_space.py::TestSingleNetworkGrid::test_move_agent", "tests/test_space.py::TestMultipleNetworkGrid::test_agent_positions", "tests/test_space.py::TestMultipleNetworkGrid::test_get_all_cell_contents", "tests/test_space.py::TestMultipleNetworkGrid::test_get_cell_list_contents", "tests/test_space.py::TestMultipleNetworkGrid::test_get_neighbors", "tests/test_space.py::TestMultipleNetworkGrid::test_is_cell_empty", "tests/test_space.py::TestMultipleNetworkGrid::test_move_agent" ]
{ "failed_lite_validators": [ "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2021-03-04 14:47:50+00:00
apache-2.0
4,683
projectmesa__mesa-1116
diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 6ed533a..a5e9c8d 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -42,8 +42,9 @@ jobs: run: pip install .[dev] - name: Test with pytest run: pytest --cov=mesa tests/ --cov-report=xml - - name: Codecov - uses: codecov/[email protected] + - if: matrix.os == 'ubuntu' + name: Codecov + uses: codecov/codecov-action@v2 lint-flake: runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a99e40..9366459 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/ambv/black - rev: stable + rev: 21.12b0 hooks: - id: black exclude: mesa/cookiecutter-mesa/* diff --git a/README.rst b/README.rst index dd2c581..2dbc660 100644 --- a/README.rst +++ b/README.rst @@ -54,7 +54,7 @@ Or any other (development) branch on this repo or your own fork: .. code-block:: bash - $ pip install -e git+https://github.com/YOUR_FORK/mesa@YOUR_BRANCH + $ pip install -e git+https://github.com/YOUR_FORK/mesa@YOUR_BRANCH#egg=mesa Take a look at the `examples <https://github.com/projectmesa/mesa/tree/main/examples>`_ folder for sample models demonstrating Mesa features. diff --git a/docs/tutorials/intro_tutorial.ipynb b/docs/tutorials/intro_tutorial.ipynb index ada5120..5e32142 100644 --- a/docs/tutorials/intro_tutorial.ipynb +++ b/docs/tutorials/intro_tutorial.ipynb @@ -229,9 +229,7 @@ }, { "cell_type": "markdown", - "metadata": { - "collapsed": true - }, + "metadata": {}, "source": [ "### Agent Step\n", "\n", @@ -1046,11 +1044,11 @@ "A dictionary containing all the parameters of the model class and desired values to use for the batch run as key-value pairs. Each value can either be fixed ( e.g. `{\"height\": 10, \"width\": 10}`) or an iterable (e.g. `{\"N\": range(10, 500, 10)}`). `batch_run` will then generate all possible parameter combinations based on this dictionary and run the model `iterations` times for each combination.\n", "<br/><br/>\n", "\n", - "* `nr_processes`\n", + "* `number_processes`\n", "<br/><br/>\n", "Number of processors used to run the sweep in parallel. Optional. If not specified, defaults to use all the available processors.\n", "<br/><br/>\n", - "Note: Multiprocessing does make debugging challenging. If your parameter sweeps are resulting in unexpected errors set `nr_processes = 1`.\n", + "Note: Multiprocessing does make debugging challenging. If your parameter sweeps are resulting in unexpected errors set `number_processes = 1`.\n", "<br/><br/>\n", "\n", "* `iterations`\n", @@ -1117,7 +1115,7 @@ " parameters=params,\n", " iterations=5,\n", " max_steps=100,\n", - " nr_processes=None,\n", + " number_processes=None,\n", " data_collection_period=1,\n", " display_progress=True,\n", ")" @@ -1328,7 +1326,7 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1342,7 +1340,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.12" + "version": "3.9.6" }, "widgets": { "state": {}, @@ -1350,5 +1348,5 @@ } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/docs/tutorials/intro_tutorial.rst b/docs/tutorials/intro_tutorial.rst index ca3cdf7..967a0dd 100644 --- a/docs/tutorials/intro_tutorial.rst +++ b/docs/tutorials/intro_tutorial.rst @@ -919,13 +919,13 @@ We call ``batch_run`` with the following arguments: will then generate all possible parameter combinations based on this dictionary and run the model ``iterations`` times for each combination. -* ``nr_processes`` +* ``number_processes`` Number of processors used to run the sweep in parallel. Optional. If not specified, defaults to use all the available processors. Note: Multiprocessing does make debugging challenging. If your - parameter sweeps are resulting in unexpected errors set ``nr_processes = 1``. + parameter sweeps are resulting in unexpected errors set ``number_processes = 1``. * ``iterations`` @@ -980,7 +980,7 @@ iteration). parameters=params, iterations=5, max_steps=100, - nr_processes=None, + number_processes=None, data_collection_period=1, display_progress=True, ) diff --git a/mesa/batchrunner.py b/mesa/batchrunner.py index 9178f0d..4b19c47 100644 --- a/mesa/batchrunner.py +++ b/mesa/batchrunner.py @@ -12,6 +12,7 @@ from collections import OrderedDict from functools import partial from itertools import count, product from multiprocessing import Pool, cpu_count +from warnings import warn from typing import ( Any, Counter, @@ -34,7 +35,7 @@ from mesa.model import Model def batch_run( model_cls: Type[Model], parameters: Mapping[str, Union[Any, Iterable[Any]]], - nr_processes: Optional[int] = None, + number_processes: Optional[int] = None, iterations: int = 1, data_collection_period: int = -1, max_steps: int = 1000, @@ -48,7 +49,7 @@ def batch_run( The model class to batch-run parameters : Mapping[str, Union[Any, Iterable[Any]]], Dictionary with model parameters over which to run the model. You can either pass single values or iterables. - nr_processes : int, optional + number_processes : int, optional Number of processes used. Set to None (default) to use all available processors iterations : int, optional Number of iterations for each parameter combination, by default 1 @@ -79,7 +80,7 @@ def batch_run( results: List[Dict[str, Any]] = [] with tqdm(total_iterations, disable=not display_progress) as pbar: - if nr_processes == 1: + if number_processes == 1: for iteration in range(iterations): for kwargs in kwargs_list: _, rawdata = process_func(kwargs) @@ -94,7 +95,7 @@ def batch_run( else: iteration_counter: Counter[Tuple[Any, ...]] = Counter() - with Pool(nr_processes) as p: + with Pool(number_processes) as p: for paramValues, rawdata in p.imap_unordered(process_func, kwargs_list): iteration_counter[paramValues] += 1 iteration = iteration_counter[paramValues] @@ -525,7 +526,8 @@ class ParameterSampler: class BatchRunner(FixedBatchRunner): - """This class is instantiated with a model class, and model parameters + """DEPRECATION WARNING: BatchRunner Class has been replaced batch_run function + This class is instantiated with a model class, and model parameters associated with one or more values. It is also instantiated with model and agent-level reporters, dictionaries mapping a variable name to a function which collects some data from the model or its agents at the end of the run @@ -579,6 +581,11 @@ class BatchRunner(FixedBatchRunner): display_progress: Display progress bar with time estimation? """ + warn( + "BatchRunner class has been replaced by batch_run function. Please see documentation.", + DeprecationWarning, + 2, + ) if variable_parameters is None: super().__init__( model_cls, @@ -604,7 +611,8 @@ class BatchRunner(FixedBatchRunner): class BatchRunnerMP(BatchRunner): - """Child class of BatchRunner, extended with multiprocessing support.""" + """DEPRECATION WARNING: BatchRunner class has been replaced by batch_run + Child class of BatchRunner, extended with multiprocessing support.""" def __init__(self, model_cls, nr_processes=None, **kwargs): """Create a new BatchRunnerMP for a given model with the given @@ -616,6 +624,11 @@ class BatchRunnerMP(BatchRunner): should start, all running in parallel. kwargs: the kwargs required for the parent BatchRunner class """ + warn( + "BatchRunnerMP class has been replaced by batch_run function. Please see documentation.", + DeprecationWarning, + 2, + ) if nr_processes is None: # identify the number of processors available on users machine available_processors = cpu_count() diff --git a/mesa/space.py b/mesa/space.py index 873fa4c..249904c 100644 --- a/mesa/space.py +++ b/mesa/space.py @@ -39,6 +39,12 @@ GridContent = Union[Optional[Agent], Set[Agent]] FloatCoordinate = Union[Tuple[float, float], np.ndarray] +def clamp(x: float, lowest: float, highest: float) -> float: + # This should be faster than np.clip for a scalar x. + # TODO: measure how much faster this function is. + return max(lowest, min(x, highest)) + + def accept_tuple_argument(wrapped_function): """Decorator to allow grid methods that take a list of (x, y) coord tuples to also handle a single position, by automatically wrapping tuple in @@ -410,12 +416,46 @@ class Grid: x, y = pos return self.grid[x][y] == self.default_val() - def move_to_empty(self, agent: Agent) -> None: + def move_to_empty( + self, agent: Agent, cutoff: float = 0.998, num_agents: Optional[int] = None + ) -> None: """Moves agent to a random empty cell, vacating agent's old cell.""" pos = agent.pos if len(self.empties) == 0: raise Exception("ERROR: No empty cells") - new_pos = agent.random.choice(sorted(self.empties)) + if num_agents is None: + try: + num_agents = agent.model.schedule.get_agent_count() + except AttributeError: + raise Exception( + "Your agent is not attached to a model, and so Mesa is unable\n" + "to figure out the total number of agents you have created.\n" + "This number is required in order to calculate the threshold\n" + "for using a much faster algorithm to find an empty cell.\n" + "In this case, you must specify `num_agents`." + ) + new_pos = (0, 0) # Initialize it with a starting value. + # This method is based on Agents.jl's random_empty() implementation. + # See https://github.com/JuliaDynamics/Agents.jl/pull/541. + # For the discussion, see + # https://github.com/projectmesa/mesa/issues/1052. + # This switch assumes the worst case (for this algorithm) of one + # agent per position, which is not true in general but is appropriate + # here. + if clamp(num_agents / (self.width * self.height), 0.0, 1.0) < cutoff: + # The default cutoff value provided is the break-even comparison + # with the time taken in the else branching point. + # The number is measured to be 0.998 in Agents.jl, but since Mesa + # run under different environment, the number is different here. + while True: + new_pos = ( + agent.random.randrange(self.width), + agent.random.randrange(self.height), + ) + if self.is_cell_empty(new_pos): + break + else: + new_pos = agent.random.choice(sorted(self.empties)) self._place_agent(new_pos, agent) agent.pos = new_pos self._remove_agent(pos, agent)
projectmesa/mesa
246c69d592a82e89c75d555c79736c3f619d434a
diff --git a/tests/test_batch_run.py b/tests/test_batch_run.py index 7d24e88..072b1da 100644 --- a/tests/test_batch_run.py +++ b/tests/test_batch_run.py @@ -141,4 +141,4 @@ def test_batch_run_no_agent_reporters(): def test_batch_run_single_core(): - batch_run(MockModel, {}, nr_processes=1, iterations=10) + batch_run(MockModel, {}, number_processes=1, iterations=10) diff --git a/tests/test_grid.py b/tests/test_grid.py index 636281f..91bdf4b 100644 --- a/tests/test_grid.py +++ b/tests/test_grid.py @@ -229,6 +229,7 @@ class TestSingleGrid(unittest.TestCase): a = MockAgent(counter, None) self.agents.append(a) self.grid.place_agent(a, (x, y)) + self.num_agents = len(self.agents) def test_enforcement(self): """ @@ -242,11 +243,14 @@ class TestSingleGrid(unittest.TestCase): # Place the agent in an empty cell self.grid.position_agent(a) + self.num_agents += 1 # Test whether after placing, the empty cells are reduced by 1 assert a.pos not in self.grid.empties assert len(self.grid.empties) == 8 for i in range(10): - self.grid.move_to_empty(a) + # Since the agents and the grid are not associated with a model, we + # must explicitly tell move_to_empty the number of agents. + self.grid.move_to_empty(a, num_agents=self.num_agents) assert len(self.grid.empties) == 8 # Place agents until the grid is full @@ -254,13 +258,14 @@ class TestSingleGrid(unittest.TestCase): for i in range(empty_cells): a = MockAgent(101 + i, None) self.grid.position_agent(a) + self.num_agents += 1 assert len(self.grid.empties) == 0 a = MockAgent(110, None) with self.assertRaises(Exception): self.grid.position_agent(a) with self.assertRaises(Exception): - self.move_to_empty(self.agents[0]) + self.move_to_empty(self.agents[0], num_agents=self.num_agents) # Number of agents at each position for testing
SingleGrid position_agent very slow for large grids It's fine for square widths of around 20 cells, but when you 200 it slows right down. It appears to be caused by the line `agent.random.choice(sorted(self.empties))` where it sorts the empties first. I guess it does this so you can replicate the results using random seed? If you don't care about replication however, it's unreasonably slow and can be fixed by using `agent.random.choice(list(self.empties))` instead (speeding it enormously). I'm not sure of the design decisions here, but maybe it's worth having two functions to make it clear or passing some sort of bool? https://mesa.readthedocs.io/en/stable/mesa.html#mesa.space.SingleGrid.position_agent
0.0
246c69d592a82e89c75d555c79736c3f619d434a
[ "tests/test_batch_run.py::test_batch_run_single_core", "tests/test_grid.py::TestSingleGrid::test_enforcement" ]
[ "tests/test_batch_run.py::test_make_model_kwargs", "tests/test_batch_run.py::test_batch_run", "tests/test_batch_run.py::test_batch_run_with_params", "tests/test_batch_run.py::test_batch_run_no_agent_reporters", "tests/test_grid.py::TestBaseGrid::test_agent_move", "tests/test_grid.py::TestBaseGrid::test_agent_positions", "tests/test_grid.py::TestBaseGrid::test_agent_remove", "tests/test_grid.py::TestBaseGrid::test_cell_agent_reporting", "tests/test_grid.py::TestBaseGrid::test_coord_iter", "tests/test_grid.py::TestBaseGrid::test_iter_cell_agent_reporting", "tests/test_grid.py::TestBaseGrid::test_listfree_cell_agent_reporting", "tests/test_grid.py::TestBaseGrid::test_listfree_iter_cell_agent_reporting", "tests/test_grid.py::TestBaseGrid::test_neighbors", "tests/test_grid.py::TestBaseGridTorus::test_agent_move", "tests/test_grid.py::TestBaseGridTorus::test_agent_positions", "tests/test_grid.py::TestBaseGridTorus::test_agent_remove", "tests/test_grid.py::TestBaseGridTorus::test_cell_agent_reporting", "tests/test_grid.py::TestBaseGridTorus::test_coord_iter", "tests/test_grid.py::TestBaseGridTorus::test_iter_cell_agent_reporting", "tests/test_grid.py::TestBaseGridTorus::test_listfree_cell_agent_reporting", "tests/test_grid.py::TestBaseGridTorus::test_listfree_iter_cell_agent_reporting", "tests/test_grid.py::TestBaseGridTorus::test_neighbors", "tests/test_grid.py::TestMultiGrid::test_agent_positions", "tests/test_grid.py::TestMultiGrid::test_neighbors", "tests/test_grid.py::TestHexGrid::test_neighbors", "tests/test_grid.py::TestHexGridTorus::test_agent_move", "tests/test_grid.py::TestHexGridTorus::test_agent_positions", "tests/test_grid.py::TestHexGridTorus::test_agent_remove", "tests/test_grid.py::TestHexGridTorus::test_cell_agent_reporting", "tests/test_grid.py::TestHexGridTorus::test_coord_iter", "tests/test_grid.py::TestHexGridTorus::test_iter_cell_agent_reporting", "tests/test_grid.py::TestHexGridTorus::test_listfree_cell_agent_reporting", "tests/test_grid.py::TestHexGridTorus::test_listfree_iter_cell_agent_reporting", "tests/test_grid.py::TestHexGridTorus::test_neighbors", "tests/test_grid.py::TestIndexing::test_int", "tests/test_grid.py::TestIndexing::test_tuple", "tests/test_grid.py::TestIndexing::test_list", "tests/test_grid.py::TestIndexing::test_torus", "tests/test_grid.py::TestIndexing::test_slice" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks", "has_pytest_match_arg" ], "has_test_patch": true, "is_lite": false }
2021-12-23 14:50:17+00:00
apache-2.0
4,684
projectmesa__mesa-1270
diff --git a/mesa/batchrunner.py b/mesa/batchrunner.py index 0556a38..b4290f2 100644 --- a/mesa/batchrunner.py +++ b/mesa/batchrunner.py @@ -128,10 +128,14 @@ def _make_model_kwargs( """ parameter_list = [] for param, values in parameters.items(): - try: - all_values = [(param, value) for value in values] - except TypeError: + if isinstance(values, str): + # The values is a single string, so we shouldn't iterate over it. all_values = [(param, values)] + else: + try: + all_values = [(param, value) for value in values] + except TypeError: + all_values = [(param, values)] parameter_list.append(all_values) all_kwargs = itertools.product(*parameter_list) kwargs_list = [dict(kwargs) for kwargs in all_kwargs] diff --git a/mesa/visualization/ModularVisualization.py b/mesa/visualization/ModularVisualization.py index e9d2548..3c302ee 100644 --- a/mesa/visualization/ModularVisualization.py +++ b/mesa/visualization/ModularVisualization.py @@ -116,7 +116,7 @@ from mesa.visualization.UserParam import UserSettableParameter if platform.system() == "Windows" and platform.python_version_tuple() >= ("3", "7"): asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) -D3_JS_FILE = "external/d3-4.13.0.min.js" +D3_JS_FILE = "external/d3-7.4.3.min.js" CHART_JS_FILE = "external/chart-3.6.1.min.js" @@ -125,10 +125,10 @@ class VisualizationElement: Defines an element of the visualization. Attributes: - package_includes: A list of external JavaScript files to include that - are part of the Mesa packages. - local_includes: A list of JavaScript files that are local to the - directory that the server is being run in. + package_includes: A list of external JavaScript and CSS files to + include that are part of the Mesa packages. + local_includes: A list of JavaScript and CSS files that are local to + the directory that the server is being run in. js_code: A JavaScript code string to instantiate the element. Methods: @@ -174,8 +174,10 @@ class PageHandler(tornado.web.RequestHandler): port=self.application.port, model_name=self.application.model_name, description=self.application.description, - package_includes=self.application.package_includes, - local_includes=self.application.local_includes, + package_js_includes=self.application.package_js_includes, + package_css_includes=self.application.package_css_includes, + local_js_includes=self.application.local_js_includes, + local_css_includes=self.application.local_css_includes, scripts=self.application.js_code, ) @@ -266,14 +268,22 @@ class ModularServer(tornado.web.Application): """Create a new visualization server with the given elements.""" # Prep visualization elements: self.visualization_elements = visualization_elements - self.package_includes = set() - self.local_includes = set() + self.package_js_includes = set() + self.package_css_includes = set() + self.local_js_includes = set() + self.local_css_includes = set() self.js_code = [] for element in self.visualization_elements: for include_file in element.package_includes: - self.package_includes.add(include_file) + if self._is_stylesheet(include_file): + self.package_css_includes.add(include_file) + else: + self.package_js_includes.add(include_file) for include_file in element.local_includes: - self.local_includes.add(include_file) + if self._is_stylesheet(include_file): + self.local_css_includes.add(include_file) + else: + self.local_js_includes.add(include_file) self.js_code.append(element.js_code) # Initializing the model @@ -338,3 +348,7 @@ class ModularServer(tornado.web.Application): webbrowser.open(url) tornado.autoreload.start() tornado.ioloop.IOLoop.current().start() + + @staticmethod + def _is_stylesheet(filename): + return filename.lower().endswith(".css") diff --git a/mesa/visualization/templates/css/visualization.css b/mesa/visualization/templates/css/visualization.css index 38d8850..9ae0af8 100644 --- a/mesa/visualization/templates/css/visualization.css +++ b/mesa/visualization/templates/css/visualization.css @@ -2,7 +2,8 @@ margin-bottom: 15px; } -div.tooltip { +/* This is specific to the Network visualization */ +div.d3tooltip { position: absolute; text-align: center; padding: 1px; diff --git a/mesa/visualization/templates/js/NetworkModule_d3.js b/mesa/visualization/templates/js/NetworkModule_d3.js index 7d3839a..110322c 100644 --- a/mesa/visualization/templates/js/NetworkModule_d3.js +++ b/mesa/visualization/templates/js/NetworkModule_d3.js @@ -22,7 +22,7 @@ const NetworkModule = function (svg_width, svg_height) { const tooltip = d3 .select("body") .append("div") - .attr("class", "tooltip") + .attr("class", "d3tooltip") .style("opacity", 0); svg.call( @@ -38,7 +38,7 @@ const NetworkModule = function (svg_width, svg_height) { this.render = function (data) { const graph = JSON.parse(JSON.stringify(data)); - simulation = d3 + const simulation = d3 .forceSimulation() .nodes(graph.nodes) .force("charge", d3.forceManyBody().strength(-80).distanceMin(2)) @@ -89,12 +89,12 @@ const NetworkModule = function (svg_width, svg_height) { .data(graph.nodes) .enter() .append("circle") - .on("mouseover", function (d) { + .on("mouseover", function (event, d) { tooltip.transition().duration(200).style("opacity", 0.9); tooltip .html(d.tooltip) - .style("left", d3.event.pageX + "px") - .style("top", d3.event.pageY + "px"); + .style("left", event.pageX + "px") + .style("top", event.pageY + "px"); }) .on("mouseout", function () { tooltip.transition().duration(500).style("opacity", 0); diff --git a/mesa/visualization/templates/js/runcontrol.js b/mesa/visualization/templates/js/runcontrol.js index e7768aa..89e58ba 100644 --- a/mesa/visualization/templates/js/runcontrol.js +++ b/mesa/visualization/templates/js/runcontrol.js @@ -190,10 +190,10 @@ const initGUI = function (model_params) { const domID = param + "_id"; sidebar.append( [ - "<div class='input-group input-group-lg'>", + "<div>", "<p><label for='" + domID + - "' class='label label-primary'>" + + "' class='badge badge-primary'>" + obj.name + "</label></p>", "<input class='model-parameter' id='" + domID + "' type='checkbox'/>", @@ -213,10 +213,10 @@ const initGUI = function (model_params) { const domID = param + "_id"; sidebar.append( [ - "<div class='input-group input-group-lg'>", + "<div>", "<p><label for='" + domID + - "' class='label label-primary'>" + + "' class='badge badge-primary'>" + obj.name + "</label></p>", "<input class='model-parameter' id='" + domID + "' type='number'/>", @@ -235,11 +235,11 @@ const initGUI = function (model_params) { const tooltipID = domID + "_tooltip"; sidebar.append( [ - "<div class='input-group input-group-lg'>", + "<div>", "<p>", "<a id='" + tooltipID + - "' data-toggle='tooltip' data-placement='top' class='label label-primary'>", + "' data-toggle='tooltip' data-placement='top' class='badge badge-primary'>", obj.name, "</a>", "</p>", @@ -278,7 +278,7 @@ const initGUI = function (model_params) { const template = [ "<p><label for='" + domID + - "' class='label label-primary'>" + + "' class='badge badge-primary'>" + obj.name + "</label></p>", "<div class='dropdown'>", diff --git a/mesa/visualization/templates/modular_template.html b/mesa/visualization/templates/modular_template.html index c185e71..5b75089 100644 --- a/mesa/visualization/templates/modular_template.html +++ b/mesa/visualization/templates/modular_template.html @@ -1,12 +1,19 @@ <!DOCTYPE html> <head> <title>{{ model_name }} (Mesa visualization)</title> - <link href="/static/external/bootstrap-3.3.7-dist/css/bootstrap.min.css" type="text/css" rel="stylesheet" /> - <link href="/static/external/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" /> + <link href="/static/external/bootstrap-4.6.1-dist/css/bootstrap.min.css" type="text/css" rel="stylesheet" /> <link href="/static/external/bootstrap-switch-3.3.4/dist/css/bootstrap3/bootstrap-switch.min.css" type="text/css" rel="stylesheet" /> - <link href="/static/external/bootstrap-slider-9.8.0/dist/css/bootstrap-slider.min.css" type="text/css" rel="stylesheet" /> + <link href="/static/external/bootstrap-slider-11.0.2/dist/css/bootstrap-slider.min.css" type="text/css" rel="stylesheet" /> <link href="/static/css/visualization.css" type="text/css" rel="stylesheet" /> + <!-- CSS includes go here --> + {% for file_name in package_css_includes %} + <link href="/static/css/{{ file_name }}" type="text/css" rel="stylesheet" /> + {% end %} + {% for file_name in local_css_includes %} + <link href="/local/{{ file_name }}" type="text/css" rel="stylesheet" /> + {% end %} + <!-- This is the Tornado template for the Modular Visualization. The Javascript code opens a WebSocket connection to the server (the port is set via the template). On every step, it receives inputs, one per module, and sends them to the associated function to render. --> @@ -14,42 +21,43 @@ <body> <!-- Navbar --> - <nav class="navbar navbar-inverse navbar-static-top"> + <nav class="navbar navbar-dark bg-dark navbar-static-top navbar-expand-md mb-3"> <div class="container"> - <div class="navbar-header"> - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> - <span class="sr-only">Toggle navigation</span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> + <button type="button" class="navbar-toggler collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> + <span class="sr-only">Toggle navigation</span> + &#x2630; + </button> <a class="navbar-brand" href="#">{{ model_name }}</a> - </div> + <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> - <li> - <a href="#" data-toggle="modal" data-target="#about" data-title="About" data-content="#about-content"> + <li class="nav-item"> + <a href="#" data-toggle="modal" data-target="#about" data-title="About" data-content="#about-content" class="nav-link"> About </a> </li> </ul> - <ul class="nav navbar-nav navbar-right"> - <li id="play-pause"><a href="#">Start</a></li> - <li id="step"><a href="#">Step</a></li> - <li id="reset"><a href="#">Reset</a></li> + <ul class="nav navbar-nav ml-auto"> + <li id="play-pause" class="nav-item"><a href="#" class="nav-link">Start</a> + </li> + <li id="step" class="nav-item"><a href="#" class="nav-link">Step</a> + </li> + <li id="reset" class="nav-item"><a href="#" class="nav-link">Reset</a> + </li> </ul> </div><!--/.nav-collapse --> </div> </nav> - <div class="container"> - <div class="col-lg-4 col-md-4 col-sm-4 col-xs-3" id="sidebar"></div> - <div class="col-lg-8 col-md-8 col-sm-8 col-xs-9" id="elements"> + <div class="container d-flex flex-row"> + <div class="col-xl-4 col-lg-4 col-md-4 col-3" id="sidebar"></div> + <div class="col-xl-8 col-lg-8 col-md-8 col-9" id="elements"> <div id="elements-topbar"> - <div class="input-group input-group-lg"> - <label class="label label-primary" for="fps" style="margin-right: 15px">Frames Per Second</label> - <input id="fps" data-slider-id='fps' type="text" /> - <p>Current Step: <span id="currentStep">0</span></p> + <div"> + <label class="badge badge-primary" for="fps" style="margin-right: 15px">Frames Per Second</label> + <input id="fps" data-slider-id="fps" type="text"> </div> + <p>Current Step: <span id="currentStep">0</span> + </p> </div> </div> </div> @@ -59,12 +67,13 @@ <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title">About {{ model_name }}</h4> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&#xD7;</span> + </button> </div> <div class="modal-body"> <div>{{ description }}</div> - <div>&nbsp;</div> + <div>&#xA0;</div> <div style="clear: both;"></div> </div> </div> @@ -73,15 +82,15 @@ <!-- Bottom-load all JavaScript dependencies --> <script src="/static/js/external/jquery-2.2.4.min.js"></script> - <script src="/static/external/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script> + <script src="/static/external/bootstrap-4.6.1-dist/js/bootstrap.bundle.min.js"></script> <script src="/static/external/bootstrap-switch-3.3.4/dist/js/bootstrap-switch.min.js"></script> - <script src="/static/external/bootstrap-slider-9.8.0/dist/bootstrap-slider.min.js"></script> + <script src="/static/external/bootstrap-slider-11.0.2/dist/bootstrap-slider.min.js"></script> <!-- Script includes go here --> - {% for file_name in package_includes %} + {% for file_name in package_js_includes %} <script src="/static/js/{{ file_name }}" type="text/javascript"></script> {% end %} - {% for file_name in local_includes %} + {% for file_name in local_js_includes %} <script src="/local/{{ file_name }}" type="text/javascript"></script> {% end %} diff --git a/setup.py b/setup.py index 9556834..044566e 100644 --- a/setup.py +++ b/setup.py @@ -66,14 +66,14 @@ def ensure_JS_dep_single(url, out_name=None): # hardcoded included files and versions in: mesa/visualization/templates/modular_template.html # Ensure Bootstrap -bootstrap_version = "3.3.7" +bootstrap_version = "4.6.1" ensure_JS_dep( f"bootstrap-{bootstrap_version}-dist", f"https://github.com/twbs/bootstrap/releases/download/v{bootstrap_version}/bootstrap-{bootstrap_version}-dist.zip", ) # Ensure Bootstrap Slider -bootstrap_slider_version = "9.8.0" +bootstrap_slider_version = "11.0.2" ensure_JS_dep( f"bootstrap-slider-{bootstrap_slider_version}", f"https://github.com/seiyria/bootstrap-slider/archive/refs/tags/v{bootstrap_slider_version}.zip", @@ -92,7 +92,7 @@ ensure_JS_dep_single( ) # Important: when updating the D3 version, make sure to update the constant # D3_JS_FILE in mesa/visualization/ModularVisualization.py. -d3_version = "4.13.0" +d3_version = "7.4.3" ensure_JS_dep_single( f"https://cdnjs.cloudflare.com/ajax/libs/d3/{d3_version}/d3.min.js", out_name=f"d3-{d3_version}.min.js",
projectmesa/mesa
eb73aac0cf7bf129a4ac93187ff76a4fd9e3ae39
diff --git a/tests/test_batch_run.py b/tests/test_batch_run.py index 072b1da..67ce3bc 100644 --- a/tests/test_batch_run.py +++ b/tests/test_batch_run.py @@ -18,6 +18,8 @@ def test_make_model_kwargs(): {"a": 1, "b": 0}, {"a": 1, "b": 1}, ] + # If the value is a single string, do not iterate over it. + assert _make_model_kwargs({"a": "value"}) == [{"a": "value"}] class MockAgent(Agent):
Migrate D3 from v4 to v7 The current D3 version that is [used in Mesa](https://github.com/projectmesa/mesa/blob/main/mesa/visualization/templates/js/d3.min.js), version [4.13.0](https://github.com/d3/d3/releases/tag/v4.13.0), is almost 4 years old. Three new major versions have been released since. Version 5.0 and 7.0 contain relatively few breaking changes, but 6.0 contains a bit more. - [Changes in D3 5.0](https://github.com/d3/d3/blob/main/CHANGES.md#changes-in-d3-50) - [D3 6.0 migration guide](https://observablehq.com/@d3/d3v6-migration-guide) - [v7.0.0 breaking changes](https://github.com/d3/d3/releases/tag/v7.0.0)
0.0
eb73aac0cf7bf129a4ac93187ff76a4fd9e3ae39
[ "tests/test_batch_run.py::test_make_model_kwargs" ]
[ "tests/test_batch_run.py::test_batch_run", "tests/test_batch_run.py::test_batch_run_with_params", "tests/test_batch_run.py::test_batch_run_no_agent_reporters", "tests/test_batch_run.py::test_batch_run_single_core" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2022-04-10 02:49:42+00:00
apache-2.0
4,685
projectmesa__mesa-1287
diff --git a/mesa/model.py b/mesa/model.py index fddf68e..6180a45 100644 --- a/mesa/model.py +++ b/mesa/model.py @@ -6,6 +6,8 @@ Core Objects: Model """ import random +from mesa.datacollection import DataCollector + # mypy from typing import Any, Optional @@ -61,3 +63,22 @@ class Model: seed = self._seed self.random.seed(seed) self._seed = seed + + def initialize_data_collector( + self, model_reporters=None, agent_reporters=None, tables=None + ) -> None: + if not hasattr(self, "schedule") or self.schedule is None: + raise RuntimeError( + "You must initialize the scheduler (self.schedule) before initializing the data collector." + ) + if self.schedule.get_agent_count() == 0: + raise RuntimeError( + "You must add agents to the scheduler before initializing the data collector." + ) + self.datacollector = DataCollector( + model_reporters=model_reporters, + agent_reporters=agent_reporters, + tables=tables, + ) + # Collect data for the first time during initialization. + self.datacollector.collect(self)
projectmesa/mesa
f4f44ad1d5fb5d30651cabc8c8557a97c7f737e6
diff --git a/tests/test_datacollector.py b/tests/test_datacollector.py index 0221b7d..0f2bd4c 100644 --- a/tests/test_datacollector.py +++ b/tests/test_datacollector.py @@ -5,7 +5,6 @@ import unittest from mesa import Model, Agent from mesa.time import BaseScheduler -from mesa.datacollection import DataCollector class MockAgent(Agent): @@ -47,7 +46,7 @@ class MockModel(Model): for i in range(10): a = MockAgent(i, self, val=i) self.schedule.add(a) - self.datacollector = DataCollector( + self.initialize_data_collector( { "total_agents": lambda m: m.schedule.get_agent_count(), "model_value": "model_val", @@ -103,10 +102,11 @@ class TestDataCollector(unittest.TestCase): assert "model_calc" in data_collector.model_vars assert "model_calc_comp" in data_collector.model_vars assert "model_calc_fail" in data_collector.model_vars - assert len(data_collector.model_vars["total_agents"]) == 7 - assert len(data_collector.model_vars["model_value"]) == 7 - assert len(data_collector.model_vars["model_calc"]) == 7 - assert len(data_collector.model_vars["model_calc_comp"]) == 7 + length = 8 + assert len(data_collector.model_vars["total_agents"]) == length + assert len(data_collector.model_vars["model_value"]) == length + assert len(data_collector.model_vars["model_calc"]) == length + assert len(data_collector.model_vars["model_calc_comp"]) == length self.step_assertion(data_collector.model_vars["total_agents"]) for element in data_collector.model_vars["model_value"]: assert element == 100 @@ -123,7 +123,7 @@ class TestDataCollector(unittest.TestCase): data_collector = self.model.datacollector agent_table = data_collector.get_agent_vars_dataframe() - assert len(data_collector._agent_records) == 7 + assert len(data_collector._agent_records) == 8 for step, records in data_collector._agent_records.items(): if step < 5: assert len(records) == 10 @@ -165,13 +165,35 @@ class TestDataCollector(unittest.TestCase): model_vars = data_collector.get_model_vars_dataframe() agent_vars = data_collector.get_agent_vars_dataframe() table_df = data_collector.get_table_dataframe("Final_Values") - assert model_vars.shape == (7, 5) - assert agent_vars.shape == (67, 2) + assert model_vars.shape == (8, 5) + assert agent_vars.shape == (77, 2) assert table_df.shape == (9, 2) with self.assertRaises(Exception): table_df = data_collector.get_table_dataframe("not a real table") +class TestDataCollectorInitialization(unittest.TestCase): + def setUp(self): + self.model = Model() + + def test_initialize_before_scheduler(self): + with self.assertRaises(RuntimeError) as cm: + self.model.initialize_data_collector() + self.assertEqual( + str(cm.exception), + "You must initialize the scheduler (self.schedule) before initializing the data collector.", + ) + + def test_initialize_before_agents_added_to_scheduler(self): + with self.assertRaises(RuntimeError) as cm: + self.model.schedule = BaseScheduler(self) + self.model.initialize_data_collector() + self.assertEqual( + str(cm.exception), + "You must add agents to the scheduler before initializing the data collector.", + ) + + if __name__ == "__main__": unittest.main()
bug: batch_run assumes model datacollector is called datacollector **Describe the bug** batch_run assumes user will call `DataCollector` `self.datacollector`. This is not annotated in the documentation, nor is it necessarily a requirement **Expected behavior** users can name their model `DataCollector` whatever they want (e.g. `self.dc`) **To Reproduce** create model and name `DataCollector` anything else and then execute model with batch_run and try to retrieve the data. **Additional context** Bug identified via students from the University of Mary Washington. They also had some very positive comments from their Professor "They keep saying "wow, that's so easy! That makes it so fun!" Thanks to you and your crew for all you do."
0.0
f4f44ad1d5fb5d30651cabc8c8557a97c7f737e6
[ "tests/test_datacollector.py::TestDataCollector::test_agent_records", "tests/test_datacollector.py::TestDataCollector::test_exports", "tests/test_datacollector.py::TestDataCollector::test_model_vars", "tests/test_datacollector.py::TestDataCollector::test_table_rows", "tests/test_datacollector.py::TestDataCollectorInitialization::test_initialize_before_agents_added_to_scheduler", "tests/test_datacollector.py::TestDataCollectorInitialization::test_initialize_before_scheduler" ]
[]
{ "failed_lite_validators": [ "has_pytest_match_arg" ], "has_test_patch": true, "is_lite": false }
2022-04-21 06:31:11+00:00
apache-2.0
4,686
projectmesa__mesa-1343
diff --git a/mesa/visualization/UserParam.py b/mesa/visualization/UserParam.py index 62b187e..3e391e7 100644 --- a/mesa/visualization/UserParam.py +++ b/mesa/visualization/UserParam.py @@ -1,3 +1,7 @@ +from numbers import Number +from warnings import warn + + NUMBER = "number" CHECKBOX = "checkbox" CHOICE = "choice" @@ -63,6 +67,13 @@ class UserSettableParameter: choices=None, description=None, ): + + warn( + "UserSettableParameter is deprecated in favor of UserParam objects " + "such as Slider, Checkbox, Choice, StaticText, NumberInput. " + "See the examples folder for how to use them. " + "UserSettableParameter will be removed in the next major release." + ) if choices is None: choices = list() if param_type not in self.TYPES: @@ -268,3 +279,19 @@ class StaticText(UserParam): self._value = value valid = isinstance(self.value, str) self.maybe_raise_error(valid) + + +class NumberInput(UserParam): + """ + a simple numerical input + + Example: + number_option = NumberInput("My Number", value=123) + """ + + def __init__(self, name="", value=None, description=None): + self.param_type = NUMBER + self.name = name + self._value = value + valid = isinstance(self.value, Number) + self.maybe_raise_error(valid)
projectmesa/mesa
991a01753ea1b3b6c956aea5ba7fccd9f2d8270b
diff --git a/tests/test_usersettableparam.py b/tests/test_usersettableparam.py index deb4da4..6dc5277 100644 --- a/tests/test_usersettableparam.py +++ b/tests/test_usersettableparam.py @@ -5,12 +5,14 @@ from mesa.visualization.UserParam import ( Checkbox, Choice, StaticText, + NumberInput, ) class TestOption(TestCase): def setUp(self): self.number_option = UserSettableParameter("number", value=123) + self.number_option_standalone = NumberInput("number", value=123) self.checkbox_option = UserSettableParameter("checkbox", value=True) self.checkbox_option_standalone = Checkbox(value=True) self.choice_option = UserSettableParameter( @@ -29,9 +31,10 @@ class TestOption(TestCase): self.static_text_option = StaticText("Hurr, Durr Im'a Sheep") def test_number(self): - assert self.number_option.value == 123 - self.number_option.value = 321 - assert self.number_option.value == 321 + for option in [self.number_option, self.number_option_standalone]: + assert option.value == 123 + option.value = 321 + assert option.value == 321 def test_checkbox(self): for option in [self.checkbox_option, self.checkbox_option_standalone]:
UX: Split UserSettableParameter into various classes What if, instead of ```python number_option = UserSettableParameter('number', 'My Number', value=123) boolean_option = UserSettableParameter('checkbox', 'My Boolean', value=True) slider_option = UserSettableParameter('slider', 'My Slider', value=123, min_value=10, max_value=200, step=0.1) ``` we do ```python number_option = Number("My Number", 123) boolean_option = Checkbox("My boolean", True) slider_option = Slider("My slider", 123, min=10, max=200, step=0.1) ``` In addition to looking simpler, more importantly, this allows users to define their own UserParam class.
0.0
991a01753ea1b3b6c956aea5ba7fccd9f2d8270b
[ "tests/test_usersettableparam.py::TestOption::test_checkbox", "tests/test_usersettableparam.py::TestOption::test_choice", "tests/test_usersettableparam.py::TestOption::test_number", "tests/test_usersettableparam.py::TestOption::test_slider", "tests/test_usersettableparam.py::TestOption::test_static_text" ]
[]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2022-05-26 06:30:43+00:00
apache-2.0
4,687
projectmesa__mesa-1413
diff --git a/.codespellignore b/.codespellignore index 4faefa4..94a0147 100644 --- a/.codespellignore +++ b/.codespellignore @@ -5,3 +5,4 @@ ist inactivate ue fpr +falsy diff --git a/mesa/batchrunner.py b/mesa/batchrunner.py index a66b13d..76d6a31 100644 --- a/mesa/batchrunner.py +++ b/mesa/batchrunner.py @@ -15,7 +15,6 @@ from multiprocessing import Pool, cpu_count from warnings import warn from typing import ( Any, - Counter, Dict, Iterable, List, @@ -67,7 +66,13 @@ def batch_run( [description] """ - kwargs_list = _make_model_kwargs(parameters) * iterations + runs_list = [] + run_id = 0 + for iteration in range(iterations): + for kwargs in _make_model_kwargs(parameters): + runs_list.append((run_id, iteration, kwargs)) + run_id += 1 + process_func = partial( _model_run_func, model_cls, @@ -75,34 +80,19 @@ def batch_run( data_collection_period=data_collection_period, ) - total_iterations = len(kwargs_list) - run_counter = count() - results: List[Dict[str, Any]] = [] - with tqdm(total=total_iterations, disable=not display_progress) as pbar: - iteration_counter: Counter[Tuple[Any, ...]] = Counter() - - def _fn(paramValues, rawdata): - iteration_counter[paramValues] += 1 - iteration = iteration_counter[paramValues] - run_id = next(run_counter) - data = [] - for run_data in rawdata: - out = {"RunId": run_id, "iteration": iteration - 1} - out.update(run_data) - data.append(out) - results.extend(data) - pbar.update() - + with tqdm(total=len(runs_list), disable=not display_progress) as pbar: if number_processes == 1: - for kwargs in kwargs_list: - paramValues, rawdata = process_func(kwargs) - _fn(paramValues, rawdata) + for run in runs_list: + data = process_func(run) + results.extend(data) + pbar.update() else: with Pool(number_processes) as p: - for paramValues, rawdata in p.imap_unordered(process_func, kwargs_list): - _fn(paramValues, rawdata) + for data in p.imap_unordered(process_func, runs_list): + results.extend(data) + pbar.update() return results @@ -140,18 +130,18 @@ def _make_model_kwargs( def _model_run_func( model_cls: Type[Model], - kwargs: Dict[str, Any], + run: Tuple[int, int, Dict[str, Any]], max_steps: int, data_collection_period: int, -) -> Tuple[Tuple[Any, ...], List[Dict[str, Any]]]: +) -> List[Dict[str, Any]]: """Run a single model run and collect model and agent data. Parameters ---------- model_cls : Type[Model] The model class to batch-run - kwargs : Dict[str, Any] - model kwargs used for this run + run: Tuple[int, int, Dict[str, Any]] + The run id, iteration number, and kwargs for this run max_steps : int Maximum number of model steps after which the model halts, by default 1000 data_collection_period : int @@ -159,9 +149,10 @@ def _model_run_func( Returns ------- - Tuple[Tuple[Any, ...], List[Dict[str, Any]]] + List[Dict[str, Any]] Return model_data, agent_data from the reporters """ + run_id, iteration, kwargs = run model = model_cls(**kwargs) while model.running and model.schedule.steps <= max_steps: model.step() @@ -178,15 +169,30 @@ def _model_run_func( # If there are agent_reporters, then create an entry for each agent if all_agents_data: stepdata = [ - {**{"Step": step}, **kwargs, **model_data, **agent_data} + { + "RunId": run_id, + "iteration": iteration, + "Step": step, + **kwargs, + **model_data, + **agent_data, + } for agent_data in all_agents_data ] # If there is only model data, then create a single entry for the step else: - stepdata = [{**{"Step": step}, **kwargs, **model_data}] + stepdata = [ + { + "RunId": run_id, + "iteration": iteration, + "Step": step, + **kwargs, + **model_data, + } + ] data.extend(stepdata) - return tuple(kwargs.values()), data + return data def _collect_data(
projectmesa/mesa
5c68906b7f7f1d96c2467695b3ee0eb18d9c01ed
diff --git a/tests/test_batch_run.py b/tests/test_batch_run.py index 4f38717..fffd422 100644 --- a/tests/test_batch_run.py +++ b/tests/test_batch_run.py @@ -50,6 +50,7 @@ class MockModel(Model): fixed_model_param=None, schedule=None, enable_agent_reporters=True, + n_agents=3, **kwargs ): super().__init__() @@ -57,7 +58,7 @@ class MockModel(Model): self.variable_model_param = variable_model_param self.variable_agent_param = variable_agent_param self.fixed_model_param = fixed_model_param - self.n_agents = 3 + self.n_agents = n_agents if enable_agent_reporters: agent_reporters = {"agent_id": "unique_id", "agent_local": "local"} else: @@ -145,3 +146,52 @@ def test_batch_run_no_agent_reporters(): def test_batch_run_single_core(): batch_run(MockModel, {}, number_processes=1, iterations=10) + + +def test_batch_run_unhashable_param(): + result = batch_run( + MockModel, + { + "n_agents": 2, + "variable_model_params": [{"key": "value"}], + }, + iterations=2, + ) + template = { + "Step": 1000, + "reported_model_param": 42, + "agent_local": 250.0, + "n_agents": 2, + "variable_model_params": {"key": "value"}, + } + + assert result == [ + { + "RunId": 0, + "iteration": 0, + "AgentID": 0, + "agent_id": 0, + **template, + }, + { + "RunId": 0, + "iteration": 0, + "AgentID": 1, + "agent_id": 1, + **template, + }, + { + "RunId": 1, + "iteration": 1, + "AgentID": 0, + "agent_id": 0, + **template, + }, + { + "RunId": 1, + "iteration": 1, + "AgentID": 1, + "agent_id": 1, + **template, + }, + ]
Batchrunner does not handle exotic input parameters? My model class takes inputs such as below: class ExampleModel(Model): def __init__(self, seed: int = 0, input_data: Type[pd.DataFrame] = pd.read_csv('InputData.csv'), scenario: str = 'baseline', social_network_parameters: dict = { "average_degree": 10, "rewiring_probability": 0.1}, year_period: int = 30, etc. ) -> None: It would be great if we could have a way to iterate through a list of strings for instance. In my case, the scenario parameter will select part of the Data Frame input based on the scenario string that is given. Ideally, I would like to give batch_run a list such as: ['baseline', 'scenario1', 'scenario2']. It seems that because the batch_run function wants to launch batches based on iterables it takes the name of my first Data Frame column as an input for the input_data parameter or the first letter of my string (i.e., 'b' in 'baseline' for the example above) for the scenario parameter. Although it was already not possible to do too many exotic things with input parameters to iterate through in the old BatchRunner classes, at least we could have strings, dictionaries, and so on as input parameters because of the "fixed_parameters" input of the BatchRunner classes. Now it seems batch_run will base its batch of simulations based on any iterable. I am not sure how that could be fixed but I think it could improve Mesa's functionalities. PS: I do love the simplicity of the new batch_run function, so I am not advocating going back to the old BatchRunner classes but just improving batch_run.
0.0
5c68906b7f7f1d96c2467695b3ee0eb18d9c01ed
[ "tests/test_batch_run.py::test_batch_run_unhashable_param" ]
[ "tests/test_batch_run.py::test_make_model_kwargs", "tests/test_batch_run.py::test_batch_run", "tests/test_batch_run.py::test_batch_run_with_params", "tests/test_batch_run.py::test_batch_run_no_agent_reporters", "tests/test_batch_run.py::test_batch_run_single_core" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2022-09-19 18:34:09+00:00
apache-2.0
4,688
projectmesa__mesa-1439
diff --git a/mesa/model.py b/mesa/model.py index 10b0a5e..aba1db9 100644 --- a/mesa/model.py +++ b/mesa/model.py @@ -21,9 +21,10 @@ class Model: def __new__(cls, *args: Any, **kwargs: Any) -> Any: """Create a new model object and instantiate its RNG automatically.""" - cls._seed = kwargs.get("seed", None) - cls.random = random.Random(cls._seed) - return object.__new__(cls) + obj = object.__new__(cls) + obj._seed = kwargs.get("seed", None) + obj.random = random.Random(obj._seed) + return obj def __init__(self, *args: Any, **kwargs: Any) -> None: """Create a new model. Overload this method with the actual code to
projectmesa/mesa
3def79dd18b5f9978c7ccda0930a818082af127f
diff --git a/tests/test_model.py b/tests/test_model.py index a326978..35ebb4a 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -28,6 +28,9 @@ def test_running(): def test_seed(seed=23): model = Model(seed=seed) assert model._seed == seed + model2 = Model(seed=seed + 1) + assert model2._seed == seed + 1 + assert model._seed == seed def test_reset_randomizer(newseed=42):
Seed and random should not be class attributes **Describe the bug** <!-- A clear and concise description the bug --> Every time a model instance is created, it updates the seed and random attribute of every other instance of the same class. **Expected behavior** <!-- A clear and concise description of what you expected to happen --> I would expect each instance to have their own attribute. This way, the behavior of each instance is independent and predictable. **To Reproduce** <!-- Steps to reproduce the bug, or a link to a project where the bug is visible --> ```pycon >>> from mesa import Model >>> class Ex(Model): ... def __init__(self, seed=2): ... pass ... >>> a = Ex(seed=1) >>> print(a._seed, a.random) 1 <random.Random object at 0x282a8d0> >>> b = Ex(seed=2) >>> print(a._seed, a.random) 2 <random.Random object at 0x282b2d0> ```
0.0
3def79dd18b5f9978c7ccda0930a818082af127f
[ "tests/test_model.py::test_seed" ]
[ "tests/test_model.py::test_model_set_up", "tests/test_model.py::test_running", "tests/test_model.py::test_reset_randomizer" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2022-10-05 09:13:52+00:00
apache-2.0
4,689
prophile__jacquard-17
diff --git a/jacquard/experiments/commands.py b/jacquard/experiments/commands.py index ffeb602..cf7e84b 100644 --- a/jacquard/experiments/commands.py +++ b/jacquard/experiments/commands.py @@ -3,8 +3,10 @@ import yaml import pathlib import datetime +import dateutil.tz from jacquard.commands import BaseCommand +from .experiment import Experiment class Launch(BaseCommand): @@ -25,26 +27,20 @@ class Launch(BaseCommand): def handle(self, config, options): """Run command.""" with config.storage.transaction() as store: - try: - experiment_config = store[ - 'experiments/%s' % options.experiment - ] - except KeyError: - print("Experiment %r not configured" % options.experiment) - return + experiment = Experiment.from_store(store, options.experiment) current_experiments = store.get('active-experiments', []) - if options.experiment in current_experiments: - print("Experiment %r already launched!" % options.experiment) + if experiment.id in current_experiments: + print("Experiment %r already launched!" % experiment.id) return store['active-experiments'] = ( current_experiments + [options.experiment] ) - experiment_config['launched'] = str(datetime.datetime.utcnow()) - store['experiments/%s' % options.experiment] = experiment_config + experiment.launched = datetime.datetime.now(dateutil.tz.tzutc()) + experiment.save(store) class Conclude(BaseCommand): @@ -78,13 +74,7 @@ class Conclude(BaseCommand): def handle(self, config, options): """Run command.""" with config.storage.transaction() as store: - try: - experiment_config = store[ - 'experiments/%s' % options.experiment - ] - except KeyError: - print("Experiment %r not configured" % options.experiment) - return + experiment = Experiment.from_store(store, options.experiment) current_experiments = store.get('active-experiments', []) @@ -98,18 +88,12 @@ class Conclude(BaseCommand): defaults = store.get('defaults', {}) # Find branch matching ID - for branch in experiment_config['branches']: - if branch['id'] == options.branch: - defaults.update(branch['settings']) - break - else: - print("Cannot find branch %r" % options.branch) - return + defaults.update(experiment.branch(options.branch)['settings']) store['defaults'] = defaults - experiment_config['concluded'] = str(datetime.datetime.utcnow()) - store['experiments/%s' % options.experiment] = experiment_config + experiment.concluded = datetime.datetime.now(dateutil.tz.tzutc()) + experiment.save(store) store['active-experiments'] = current_experiments @@ -146,15 +130,46 @@ class Load(BaseCommand): print("No branches specified.") return - experiment_id = definition['id'] + experiment = Experiment.from_json(definition) with config.storage.transaction() as store: live_experiments = store.get('active-experiments', ()) - if experiment_id in live_experiments: + if experiment.id in live_experiments: print( - "Experiment %r is live, refusing to edit" % experiment_id, + "Experiment %r is live, refusing to edit" % experiment.id, ) return - store['experiments/%s' % experiment_id] = definition + experiment.save(store) + + +class ListExperiments(BaseCommand): + """ + List all experiments. + + Mostly useful in practice when one cannot remember the ID of an experiment. + """ + + help = "list all experiments" + + def handle(self, config, options): + """Run command.""" + with config.storage.transaction() as store: + for experiment in Experiment.enumerate(store): + if experiment.name == experiment.id: + title = experiment.id + else: + title = '%s: %s' % (experiment.id, experiment.name) + print(title) + print('=' * len(title)) + print() + if experiment.launched: + print('Launched: %s' % experiment.launched) + if experiment.concluded: + print('Concluded: %s' % experiment.concluded) + else: + print('In progress') + else: + print('Not yet launched') + print() diff --git a/jacquard/experiments/experiment.py b/jacquard/experiments/experiment.py new file mode 100644 index 0000000..0c732e7 --- /dev/null +++ b/jacquard/experiments/experiment.py @@ -0,0 +1,124 @@ +"""Experiment definition abstraction class.""" + +import contextlib +import dateutil.parser + + +class Experiment(object): + """ + The definition of an experiment. + + This is essentially a plain-old-data class with utility methods for + canonical serialisation and deserialisation of various flavours. + """ + + def __init__( + self, + experiment_id, + branches, + *, + constraints=None, + name=None, + launched=None, + concluded=None + ): + """Base constructor. Takes all the arguments.""" + self.id = experiment_id + self.branches = branches + self.constraints = constraints or {} + self.name = name or self.id + self.launched = launched + self.concluded = concluded + + @classmethod + def from_json(cls, obj): + """ + Create instance from a JSON-esque definition. + + Required keys: id, branches + + Optional keys: name, constraints, launched, concluded + """ + kwargs = {} + + with contextlib.suppress(KeyError): + kwargs['name'] = obj['name'] + + with contextlib.suppress(KeyError): + kwargs['constraints'] = obj['constraints'] + + with contextlib.suppress(KeyError): + kwargs['launched'] = dateutil.parser.parse(obj['launched']) + + with contextlib.suppress(KeyError): + kwargs['concluded'] = dateutil.parser.parse(obj['concluded']) + + return cls(obj['id'], obj['branches'], **kwargs) + + @classmethod + def from_store(cls, store, experiment_id): + """Create instance from a store lookup by ID.""" + json_repr = dict(store['experiments/%s' % experiment_id]) + # Be resilient to missing ID + if 'id' not in json_repr: + json_repr['id'] = experiment_id + return cls.from_json(json_repr) + + @classmethod + def enumerate(cls, store): + """ + Iterator over all named experiments in a store. + + Includes inactive experiments. + """ + prefix = 'experiments/' + + for key in store: + if not key.startswith(prefix): + continue + + experiment_id = key[len(prefix):] + yield cls.from_store(store, experiment_id) + + def to_json(self): + """Serialise as canonical JSON.""" + representation = { + 'id': self.id, + 'branches': self.branches, + 'constraints': self.constraints, + 'name': self.name, + 'launched': str(self.launched), + 'concluded': str(self.concluded), + } + + if not representation['constraints']: + del representation['constraints'] + + if representation['name'] == self.id: + del representation['name'] + + if representation['launched'] == 'None': + del representation['launched'] + + if representation['concluded'] == 'None': + del representation['concluded'] + + return representation + + def save(self, store): + """Save into the given store using the ID as the key.""" + store['experiments/%s' % self.id] = self.to_json() + + def branch(self, branch_id): + """ + Get the branch with a given ID. + + In case of multiple branches with the same ID (which should Never Ever + Happen), behaviour is undefined. + + If there is no such branch, LookupErrors will materialise. + """ + for branch in self.branches: + if branch['id'] == branch_id: + return branch + raise LookupError("No such branch: %r" % branch_id) diff --git a/jacquard/service/wsgi.py b/jacquard/service/wsgi.py index 594e003..b0745da 100644 --- a/jacquard/service/wsgi.py +++ b/jacquard/service/wsgi.py @@ -7,6 +7,7 @@ import werkzeug.exceptions from jacquard.users import get_settings from jacquard.users.settings import branch_hash from jacquard.experiments.constraints import meets_constraints +from jacquard.experiments.experiment import Experiment def on_root(config): @@ -44,23 +45,17 @@ def on_experiments(config): """ with config.storage.transaction() as store: active_experiments = store.get('active-experiments', ()) - experiments = [] - - for key in store: - if not key.startswith('experiments/'): - continue - definition = store[key] - experiments.append(definition) + experiments = list(Experiment.enumerate(store)) return [ { - 'id': experiment['id'], - 'url': '/experiment/%s' % experiment['id'], + 'id': experiment.id, + 'url': '/experiment/%s' % experiment.id, 'state': 'active' - if experiment['id'] in active_experiments + if experiment.id in active_experiments else 'inactive', - 'name': experiment.get('name', experiment['id']), + 'name': experiment.name, } for experiment in experiments ] @@ -78,15 +73,13 @@ def on_experiment(config, experiment): Provided for reporting tooling which runs statistics. """ with config.storage.transaction() as store: - experiment_config = store['experiments/%s' % experiment] + experiment_config = Experiment.from_store(store, experiment) - branch_ids = [branch['id'] for branch in experiment_config['branches']] + branch_ids = [branch['id'] for branch in experiment_config.branches] branches = {x: [] for x in branch_ids} - constraints = experiment_config.get('constraints', {}) - for user_entry in config.directory.all_users(): - if not meets_constraints(constraints, user_entry): + if not meets_constraints(experiment_config.constraints, user_entry): continue branch_id = branch_ids[ @@ -97,10 +90,10 @@ def on_experiment(config, experiment): branches[branch_id].append(user_entry.id) return { - 'id': experiment_config['id'], - 'name': experiment_config.get('name', experiment_config['id']), - 'launched': experiment_config.get('launched'), - 'concluded': experiment_config.get('concluded'), + 'id': experiment_config.id, + 'name': experiment_config.name, + 'launched': experiment_config.launched, + 'concluded': experiment_config.concluded, 'branches': branches, } diff --git a/jacquard/storage/dummy.py b/jacquard/storage/dummy.py index c3e4c34..ca7dfc4 100644 --- a/jacquard/storage/dummy.py +++ b/jacquard/storage/dummy.py @@ -24,6 +24,10 @@ class DummyStore(StorageEngine): else: self.data = {} + def __getitem__(self, key): + """Direct item access. This is for test usage.""" + return json.loads(self.data.get(key, 'null')) + def begin(self): """Begin transaction.""" pass diff --git a/jacquard/users/settings.py b/jacquard/users/settings.py index 21c1687..1063f88 100644 --- a/jacquard/users/settings.py +++ b/jacquard/users/settings.py @@ -2,6 +2,7 @@ import hashlib +from jacquard.experiments.experiment import Experiment from jacquard.experiments.constraints import meets_constraints @@ -20,32 +21,30 @@ def get_settings(user_id, storage, directory=None): live_experiments = store.get('active-experiments', []) experiment_definitions = [ - {**store['experiments/%s' % x], 'id': x} + Experiment.from_store(store, x) for x in live_experiments ] overrides = store.get('overrides/%s' % user_id, {}) experiment_settings = {} - for experiment_def in experiment_definitions: - constraints = experiment_def.get('constraints', {}) - - if constraints: + for experiment in experiment_definitions: + if experiment.constraints: if directory is None: raise ValueError( "Cannot evaluate constraints on experiment %r " - "with no directory" % experiment_def['id'], + "with no directory" % experiment.id, ) user_entry = directory.lookup(user_id) - if not meets_constraints(constraints, user_entry): + if not meets_constraints(experiment.constraints, user_entry): continue - branch = experiment_def['branches'][branch_hash( - experiment_def['id'], + branch = experiment.branches[branch_hash( + experiment.id, user_id, - ) % len(experiment_def['branches'])] + ) % len(experiment.branches)] experiment_settings.update(branch['settings']) return {**defaults, **experiment_settings, **overrides} diff --git a/setup.py b/setup.py index 760e76f..d0102b6 100644 --- a/setup.py +++ b/setup.py @@ -68,6 +68,7 @@ setup( 'launch = jacquard.experiments.commands:Launch', 'conclude = jacquard.experiments.commands:Conclude', 'load-experiment = jacquard.experiments.commands:Load', + 'list = jacquard.experiments.commands:ListExperiments', 'list-users = jacquard.directory.commands:ListUsers', ), 'jacquard.directory_engines': (
prophile/jacquard
e70c7df43d5b71f59da265d830d74f7424c7d7b3
diff --git a/jacquard/experiments/tests/test_smoke.py b/jacquard/experiments/tests/test_smoke.py new file mode 100644 index 0000000..e9d5acb --- /dev/null +++ b/jacquard/experiments/tests/test_smoke.py @@ -0,0 +1,61 @@ +import datetime +import dateutil.tz + +from unittest.mock import Mock + +from jacquard.cli import main +from jacquard.storage.dummy import DummyStore + + +BRANCH_SETTINGS = {'pony': 'gravity'} + +DUMMY_DATA_PRE_LAUNCH = { + 'experiments/foo': { + 'branches': [ + {'id': 'bar', 'settings': BRANCH_SETTINGS}, + ], + }, +} + +DUMMY_DATA_POST_LAUNCH = { + 'experiments/foo': { + 'branches': [ + {'id': 'bar', 'settings': BRANCH_SETTINGS}, + ], + 'launched': str(datetime.datetime.now(dateutil.tz.tzutc())), + }, + 'active-experiments': ['foo'], +} + + +def test_launch(): + config = Mock() + config.storage = DummyStore('', data=DUMMY_DATA_PRE_LAUNCH) + + main(('launch', 'foo'), config=config) + + assert 'launched' in config.storage['experiments/foo'] + assert 'concluded' not in config.storage['experiments/foo'] + assert 'foo' in config.storage['active-experiments'] + + +def test_conclude_no_branch(): + config = Mock() + config.storage = DummyStore('', data=DUMMY_DATA_POST_LAUNCH) + + main(('conclude', 'foo', '--no-promote-branch'), config=config) + + assert 'concluded' in config.storage['experiments/foo'] + assert 'foo' not in config.storage['active-experiments'] + assert not config.storage['defaults'] + + +def test_conclude_updates_defaults(): + config = Mock() + config.storage = DummyStore('', data=DUMMY_DATA_POST_LAUNCH) + + main(('conclude', 'foo', 'bar'), config=config) + + assert 'concluded' in config.storage['experiments/foo'] + assert 'foo' not in config.storage['active-experiments'] + assert config.storage['defaults'] == BRANCH_SETTINGS diff --git a/jacquard/service/tests/test_http.py b/jacquard/service/tests/test_http.py new file mode 100644 index 0000000..05aaebf --- /dev/null +++ b/jacquard/service/tests/test_http.py @@ -0,0 +1,92 @@ +import json + +import datetime +import dateutil.tz + +from unittest.mock import Mock + +from jacquard.service import get_wsgi_app +from jacquard.storage.dummy import DummyStore +from jacquard.directory.base import UserEntry +from jacquard.directory.dummy import DummyDirectory + +import werkzeug.test + + +def get_status(path): + config = Mock() + config.storage = DummyStore('', data={ + 'defaults': {'pony': 'gravity'}, + 'active-experiments': ['foo'], + 'experiments/foo': { + 'id': 'foo', + 'constraints': { + 'excluded_tags': ['excluded'], + 'anonymous': False, + }, + 'branches': [{'id': 'bar', 'settings': {'pony': 'horse'}}], + }, + }) + now = datetime.datetime.now(dateutil.tz.tzutc()) + config.directory = DummyDirectory(users=( + UserEntry(id=1, join_date=now, tags=('excluded',)), + UserEntry(id=2, join_date=now, tags=('excluded',)), + UserEntry(id=3, join_date=now, tags=()), + )) + + wsgi = get_wsgi_app(config) + test_client = werkzeug.test.Client(wsgi) + + data, status, headers = test_client.get(path) + all_data = b''.join(data) + return status, all_data + + +def get(path): + status, all_data = get_status(path) + assert status == '200 OK' + return json.loads(all_data.decode('utf-8')) + + +def test_root(): + assert get('/') == { + 'experiments': '/experiment', + 'user': '/users/<user>', + } + + +def test_user_lookup(): + assert get('/users/1') == { + 'user': '1', + 'pony': 'gravity', + } + + +def test_user_lookup_with_non_numeric_id(): + assert get('/users/bees') == { + 'user': 'bees', + 'pony': 'gravity', + } + + +def test_experiments_list(): + # Verify no exceptions + assert get('/experiment') == [{ + 'id': 'foo', + 'url': '/experiment/foo', + 'state': 'active', + 'name': 'foo', + }] + + +def test_experiment_get_smoke(): + # Verify no exceptions + assert get('/experiment/foo')['name'] == 'foo' + + +def test_experiment_get_membership(): + assert get('/experiment/foo')['branches']['bar'] == [3] + + +def test_missing_paths_get_404(): + assert get_status('/missing')[0] == '404 NOT FOUND'
Refactor experiments into `jacquard.experiments` Currently various users analyse the experiment data structure directly. It needs to be migrated to a Python class within `jacquard.experiments`.
0.0
e70c7df43d5b71f59da265d830d74f7424c7d7b3
[ "jacquard/experiments/tests/test_smoke.py::test_launch", "jacquard/experiments/tests/test_smoke.py::test_conclude_no_branch", "jacquard/experiments/tests/test_smoke.py::test_conclude_updates_defaults" ]
[]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_added_files", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2017-01-15 23:44:38+00:00
mit
4,690
prophile__jacquard-56
diff --git a/jacquard/cli.py b/jacquard/cli.py index 263ae91..a2e102e 100644 --- a/jacquard/cli.py +++ b/jacquard/cli.py @@ -115,7 +115,7 @@ def main(args=sys.argv[1:], config=None): options.func(config, options) except CommandError as exc: (message,) = exc.args - sys.stderr.write("%s\n", message) + print(message, file=sys.stderr) exit(1) diff --git a/jacquard/experiments/commands.py b/jacquard/experiments/commands.py index d93fee3..dcdf99d 100644 --- a/jacquard/experiments/commands.py +++ b/jacquard/experiments/commands.py @@ -91,6 +91,7 @@ class Conclude(BaseCommand): experiment = Experiment.from_store(store, options.experiment) current_experiments = store.get('active-experiments', []) + concluded_experiments = store.get('concluded-experiments', []) if options.experiment not in current_experiments: raise CommandError( @@ -98,6 +99,7 @@ class Conclude(BaseCommand): ) current_experiments.remove(options.experiment) + concluded_experiments.append(options.experiment) close( store, @@ -118,6 +120,7 @@ class Conclude(BaseCommand): experiment.save(store) store['active-experiments'] = current_experiments + store['concluded-experiments'] = concluded_experiments class Load(BaseCommand): @@ -143,7 +146,7 @@ class Load(BaseCommand): parser.add_argument( '--skip-launched', action='store_true', - help="do not error on launched experiments", + help="do not load or error on launched experiments", ) @retrying @@ -151,6 +154,7 @@ class Load(BaseCommand): """Run command.""" with config.storage.transaction() as store: live_experiments = store.get('active-experiments', ()) + concluded_experiments = store.get('concluded-experiments', ()) for file in options.files: definition = yaml.safe_load(file) @@ -167,6 +171,16 @@ class Load(BaseCommand): experiment.id, ) + elif experiment.id in concluded_experiments: + if options.skip_launched: + continue + + else: + raise CommandError( + "Experiment %r has concluded, refusing to edit" % + experiment.id, + ) + experiment.save(store)
prophile/jacquard
d6bafbb05c7effddbbe7c84b3310e3c2cde31930
diff --git a/jacquard/experiments/tests/test_smoke.py b/jacquard/experiments/tests/test_smoke.py index 2b10c85..4839686 100644 --- a/jacquard/experiments/tests/test_smoke.py +++ b/jacquard/experiments/tests/test_smoke.py @@ -1,6 +1,10 @@ +import io +import copy import datetime -from unittest.mock import Mock +import contextlib +from unittest.mock import Mock, patch +import pytest import dateutil.tz from jacquard.cli import main @@ -46,6 +50,7 @@ def test_conclude_no_branch(): assert 'concluded' in config.storage['experiments/foo'] assert 'foo' not in config.storage['active-experiments'] + assert 'foo' in config.storage['concluded-experiments'] assert not config.storage['defaults'] @@ -57,4 +62,107 @@ def test_conclude_updates_defaults(): assert 'concluded' in config.storage['experiments/foo'] assert 'foo' not in config.storage['active-experiments'] + assert 'foo' in config.storage['concluded-experiments'] assert config.storage['defaults'] == BRANCH_SETTINGS + + +def test_load_after_launch_errors(): + config = Mock() + config.storage = DummyStore('', data=DUMMY_DATA_POST_LAUNCH) + + experiment_data = {'id': 'foo'} + experiment_data.update(DUMMY_DATA_PRE_LAUNCH['experiments/foo']) + + stderr = io.StringIO() + with contextlib.redirect_stderr(stderr), pytest.raises(SystemExit): + with patch( + 'jacquard.experiments.commands.yaml.safe_load', + return_value=experiment_data, + ), patch( + 'jacquard.experiments.commands.argparse.FileType', + return_value=str, + ): + main(('load-experiment', 'foo.yaml'), config=config) + + stderr_content = stderr.getvalue() + assert "Experiment 'foo' is live, refusing to edit" in stderr_content + + fresh_data = DummyStore('', data=DUMMY_DATA_POST_LAUNCH) + assert fresh_data.data == config.storage.data, "Data should be unchanged" + + +def test_load_after_launch_with_skip_launched(): + config = Mock() + config.storage = DummyStore('', data=DUMMY_DATA_POST_LAUNCH) + + experiment_data = {'id': 'foo'} + experiment_data.update(DUMMY_DATA_PRE_LAUNCH['experiments/foo']) + + stderr = io.StringIO() + with contextlib.redirect_stderr(stderr), patch( + 'jacquard.experiments.commands.yaml.safe_load', + return_value=experiment_data, + ), patch( + 'jacquard.experiments.commands.argparse.FileType', + return_value=str, + ): + main(('load-experiment', '--skip-launched', 'foo.yaml'), config=config) + + fresh_data = DummyStore('', data=DUMMY_DATA_POST_LAUNCH) + assert fresh_data.data == config.storage.data, "Data should be unchanged" + + stderr_content = stderr.getvalue() + assert '' == stderr_content + + +def test_load_after_conclude_errors(): + config = Mock() + config.storage = DummyStore('', data=DUMMY_DATA_POST_LAUNCH) + + main(('conclude', 'foo', 'bar'), config=config) + original_data = copy.deepcopy(config.storage.data) + + experiment_data = {'id': 'foo'} + experiment_data.update(DUMMY_DATA_PRE_LAUNCH['experiments/foo']) + + stderr = io.StringIO() + with contextlib.redirect_stderr(stderr), pytest.raises(SystemExit): + with patch( + 'jacquard.experiments.commands.yaml.safe_load', + return_value=experiment_data, + ), patch( + 'jacquard.experiments.commands.argparse.FileType', + return_value=str, + ): + main(('load-experiment', 'foo.yaml'), config=config) + + assert original_data == config.storage.data, "Data should be unchanged" + + stderr_content = stderr.getvalue() + assert "Experiment 'foo' has concluded, refusing to edit" in stderr_content + + +def test_load_after_conclude_with_skip_launched(): + config = Mock() + config.storage = DummyStore('', data=DUMMY_DATA_POST_LAUNCH) + + main(('conclude', 'foo', 'bar'), config=config) + original_data = copy.deepcopy(config.storage.data) + + experiment_data = {'id': 'foo'} + experiment_data.update(DUMMY_DATA_PRE_LAUNCH['experiments/foo']) + + stderr = io.StringIO() + with contextlib.redirect_stderr(stderr), patch( + 'jacquard.experiments.commands.yaml.safe_load', + return_value=experiment_data, + ), patch( + 'jacquard.experiments.commands.argparse.FileType', + return_value=str, + ): + main(('load-experiment', '--skip-launched', 'foo.yaml'), config=config) + + assert original_data == config.storage.data, "Data should be unchanged" + + stderr_content = stderr.getvalue() + assert '' == stderr_content diff --git a/jacquard/tests/test_cli.py b/jacquard/tests/test_cli.py index bae650f..bf32262 100644 --- a/jacquard/tests/test_cli.py +++ b/jacquard/tests/test_cli.py @@ -3,7 +3,9 @@ import textwrap import contextlib import unittest.mock -from jacquard.cli import main +import pytest + +from jacquard.cli import CommandError, main from jacquard.storage.dummy import DummyStore @@ -59,3 +61,28 @@ def test_run_write_command(): assert output.getvalue() == '' assert config.storage.data == {'defaults': '{"foo": "bar"}'} + + +def test_erroring_command(): + config = unittest.mock.Mock() + + ERROR_MESSAGE = "MOCK ERROR: Something went wrong in the" + + mock_parser = unittest.mock.Mock() + mock_options = unittest.mock.Mock() + mock_options.func = unittest.mock.Mock( + side_effect=CommandError(ERROR_MESSAGE), + ) + mock_parser.parse_args = unittest.mock.Mock( + return_value=mock_options, + ) + + stderr = io.StringIO() + with contextlib.redirect_stderr(stderr), pytest.raises(SystemExit): + with unittest.mock.patch( + 'jacquard.cli.argument_parser', + return_value=mock_parser, + ): + main(['command'], config=config) + + assert stderr.getvalue() == ERROR_MESSAGE + "\n"
`jacquard load-experiment` erases `concluded` dates
0.0
d6bafbb05c7effddbbe7c84b3310e3c2cde31930
[ "jacquard/tests/test_cli.py::test_erroring_command" ]
[]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2017-06-16 22:58:44+00:00
mit
4,691
protolambda__remerkleable-2
diff --git a/remerkleable/complex.py b/remerkleable/complex.py index c92fa0c..e65160f 100644 --- a/remerkleable/complex.py +++ b/remerkleable/complex.py @@ -668,8 +668,12 @@ class Container(ComplexView): raise Exception("cannot have both a backing and elements to init List") return super().__new__(cls, backing=backing, hook=hook, **kwargs) + diff = set(kwargs.keys()).difference(set(cls.fields().keys())) + if len(diff) > 0: + raise AttributeError(f'The field names {diff} are not defined in {cls}') + input_nodes = [] - for i, (fkey, ftyp) in enumerate(cls.fields().items()): + for fkey, ftyp in cls.fields().items(): fnode: Node if fkey in kwargs: finput = kwargs.pop(fkey)
protolambda/remerkleable
1a9b6bbea6f6737f5eed9deee6922a7ff7c1d49f
diff --git a/remerkleable/test_typing.py b/remerkleable/test_typing.py index 87fed19..dd20833 100644 --- a/remerkleable/test_typing.py +++ b/remerkleable/test_typing.py @@ -164,6 +164,12 @@ def test_container(): except AttributeError: pass + try: + Foo(wrong_field_name=100) + assert False + except AttributeError: + pass + def test_container_unpack(): class Foo(Container):
Check if the field name is valid when initialize a Container object ### Issue Currently, the following call is valid: ```sh >>> from eth2spec.phase0 import spec >>> x = spec.AttestationData(bar=1000) >>> x AttestationData(Container) slot: Slot = 0 index: CommitteeIndex = 0 beacon_block_root: Root = 0x0000000000000000000000000000000000000000000000000000000000000000 source: Checkpoint = Checkpoint(Container) epoch: Epoch = 0 root: Root = 0x0000000000000000000000000000000000000000000000000000000000000000 target: Checkpoint = Checkpoint(Container) epoch: Epoch = 0 root: Root = 0x0000000000000000000000000000000000000000000000000000000000000000 ``` I suppose it should have thrown an exception since `bar` is not a valid field in `AttestationData`. ### How to solve it Add check in `Container.__new__` ```python diff = set(kwargs.keys()).difference(set(fields.keys())) if len(diff) > 0: raise Exception(f'The field name {diff} is not defined in {cls}') ```
0.0
1a9b6bbea6f6737f5eed9deee6922a7ff7c1d49f
[ "remerkleable/test_typing.py::test_container" ]
[ "remerkleable/test_typing.py::test_subclasses", "remerkleable/test_typing.py::test_basic_instances", "remerkleable/test_typing.py::test_basic_value_bounds", "remerkleable/test_typing.py::test_container_unpack", "remerkleable/test_typing.py::test_list", "remerkleable/test_typing.py::test_bytesn_subclass", "remerkleable/test_typing.py::test_uint_math", "remerkleable/test_typing.py::test_container_depth", "remerkleable/test_typing.py::test_tree_depth[0-0]", "remerkleable/test_typing.py::test_tree_depth[1-0]", "remerkleable/test_typing.py::test_tree_depth[2-1]", "remerkleable/test_typing.py::test_tree_depth[3-2]", "remerkleable/test_typing.py::test_tree_depth[4-2]", "remerkleable/test_typing.py::test_tree_depth[5-3]", "remerkleable/test_typing.py::test_tree_depth[6-3]", "remerkleable/test_typing.py::test_tree_depth[7-3]", "remerkleable/test_typing.py::test_tree_depth[8-3]", "remerkleable/test_typing.py::test_tree_depth[9-4]", "remerkleable/test_typing.py::test_paths", "remerkleable/test_typing.py::test_bitvector", "remerkleable/test_typing.py::test_bitvector_iter", "remerkleable/test_typing.py::test_bitlist", "remerkleable/test_typing.py::test_bitlist_iter" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2020-04-28 05:06:31+00:00
mit
4,692
protolambda__remerkleable-21
diff --git a/remerkleable/bitfields.py b/remerkleable/bitfields.py index 1434c8c..66b4e51 100644 --- a/remerkleable/bitfields.py +++ b/remerkleable/bitfields.py @@ -326,6 +326,8 @@ class Bitlist(BitsView): @classmethod def navigate_type(cls, key: Any) -> Type[View]: + if key == '__len__': + return uint256 bit_limit = cls.limit() if key < 0 or key >= bit_limit: raise KeyError diff --git a/remerkleable/complex.py b/remerkleable/complex.py index 4574d16..5971925 100644 --- a/remerkleable/complex.py +++ b/remerkleable/complex.py @@ -461,6 +461,8 @@ class List(MonoSubtreeView): @classmethod def navigate_type(cls, key: Any) -> Type[View]: + if key == '__len__': + return uint256 if key >= cls.limit(): raise KeyError return super().navigate_type(key)
protolambda/remerkleable
91ed092d08ef0ba5ab076f0a34b0b371623db728
diff --git a/remerkleable/test_typing.py b/remerkleable/test_typing.py index 4c8ee2a..6862414 100644 --- a/remerkleable/test_typing.py +++ b/remerkleable/test_typing.py @@ -347,12 +347,21 @@ def test_paths(): assert (Wrapper / 'b' / 'quix').navigate_view(w) == 42 assert (List[uint32, 123] / 0).navigate_type() == uint32 + assert (List[uint32, 123] / "__len__").navigate_type() == uint256 try: (List[uint32, 123] / 123).navigate_type() assert False except KeyError: pass + assert (Bitlist[123] / 0).navigate_type() == boolean + assert (Bitlist[123] / "__len__").navigate_type() == uint256 + try: + (Bitlist[123] / 123).navigate_type() + assert False + except KeyError: + pass + def test_bitvector(): for size in [1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 65, 511, 512, 513, 1023, 1024, 1025]:
Error when computing `__len__` generalized index on `List` type The following code fails when using the [`get_generalized_indices` function defined in the `consensus-specs`](https://github.com/ethereum/consensus-specs/blob/cdb6725275ea9aaa6d4a323c72be59cc34b458a3/pysetup/spec_builders/altair.py#L30): ```python index = get_generalized_index(List[uint8, 256], "__len__") print(index) ``` with: ``` if key >= cls.limit(): TypeError: '>=' not supported between instances of 'str' and 'int' ``` from here: https://github.com/protolambda/remerkleable/blob/91ed092d08ef0ba5ab076f0a34b0b371623db728/remerkleable/complex.py#L464 I would think this method should be extended to avoid this check for the special key `__len__`. Happy to open a PR if this is the preferred route!
0.0
91ed092d08ef0ba5ab076f0a34b0b371623db728
[ "remerkleable/test_typing.py::test_paths" ]
[ "remerkleable/test_typing.py::test_subclasses", "remerkleable/test_typing.py::test_basic_instances", "remerkleable/test_typing.py::test_basic_value_bounds", "remerkleable/test_typing.py::test_container", "remerkleable/test_typing.py::test_container_unpack", "remerkleable/test_typing.py::test_list", "remerkleable/test_typing.py::test_bytesn_subclass", "remerkleable/test_typing.py::test_uint_math", "remerkleable/test_typing.py::test_container_depth", "remerkleable/test_typing.py::test_tree_depth[0-0]", "remerkleable/test_typing.py::test_tree_depth[1-0]", "remerkleable/test_typing.py::test_tree_depth[2-1]", "remerkleable/test_typing.py::test_tree_depth[3-2]", "remerkleable/test_typing.py::test_tree_depth[4-2]", "remerkleable/test_typing.py::test_tree_depth[5-3]", "remerkleable/test_typing.py::test_tree_depth[6-3]", "remerkleable/test_typing.py::test_tree_depth[7-3]", "remerkleable/test_typing.py::test_tree_depth[8-3]", "remerkleable/test_typing.py::test_tree_depth[9-4]", "remerkleable/test_typing.py::test_bitvector", "remerkleable/test_typing.py::test_bitvector_iter", "remerkleable/test_typing.py::test_bitlist", "remerkleable/test_typing.py::test_bitlist_iter", "remerkleable/test_typing.py::test_bitlist_access", "remerkleable/test_typing.py::test_container_inheritance", "remerkleable/test_typing.py::test_union" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2024-02-19 17:45:13+00:00
mit
4,693
pseudonym117__Riot-Watcher-118
diff --git a/.gitignore b/.gitignore index 17341c6..f3a28e9 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,4 @@ target/ .vscode/ api_key +.venv diff --git a/README.rst b/README.rst index b7d555e..d0482ad 100644 --- a/README.rst +++ b/README.rst @@ -7,7 +7,7 @@ Check for full (read: slightly better) documentation `here <http://riot-watcher. RiotWatcher is a thin wrapper on top of the `Riot Games API for League of Legends <https://developer.riotgames.com/>`__. All public methods as -of 1/7/2019 are supported in full. +of 4/19/2019 are supported in full. RiotWatcher by default supports a naive rate limiter. This rate limiter will try to stop you from making too many requests, and in a single threaded test @@ -114,6 +114,8 @@ vNext - Unlreleased Removed deprecated v3 endpoints +Add support for league v4 entry/by-summoner and entry/queue/tier/division endpoints + v2.5.0 - 1/7/2019 ~~~~~~~~~~~~~~~~~ diff --git a/src/riotwatcher/_apis/LeagueApiV4.py b/src/riotwatcher/_apis/LeagueApiV4.py index 945fcaa..a0cd40d 100644 --- a/src/riotwatcher/_apis/LeagueApiV4.py +++ b/src/riotwatcher/_apis/LeagueApiV4.py @@ -65,8 +65,40 @@ class LeagueApiV4(NamedEndpoint): url, query = LeagueApiV4Urls.by_id(region=region, league_id=league_id) return self._raw_request(self.by_id.__name__, region, url, query) + def by_summoner(self, region, encrypted_summoner_id): + """ + Get league entries in all queues for a given summoner ID + + :param string region: the region to execute this request on + :param string encrypted_summoner_id: the summoner ID to query + + :returns: Set[LeagueEntryDTO] + """ + url, query = LeagueApiV4Urls.by_summoner( + region=region, encrypted_summoner_id=encrypted_summoner_id + ) + return self._raw_request(self.by_summoner.__name__, region, url, query) + + def entries(self, region, queue, tier, division): + """ + Get all the league entries + + :param string region: the region to execute this request on + :param string queue: the queue to query, i.e. RANKED_SOLO_5x5 + :param string tier: the tier to query, i.e. DIAMOND + :param string division: the division to query, i.e. III + + :returns: Set[LeagueEntryDTO] + """ + url, query = LeagueApiV4Urls.entries( + region=region, queue=queue, tier=tier, division=division + ) + return self._raw_request(self.entries.__name__, region, url, query) + def positions_by_summoner(self, region, encrypted_summoner_id): """ + DEPRECATED + Get league positions in all queues for a given summoner ID :param string region: the region to execute this request on diff --git a/src/riotwatcher/_apis/urls/LeagueApiUrls.py b/src/riotwatcher/_apis/urls/LeagueApiUrls.py index a45f1c2..0e0ffb2 100644 --- a/src/riotwatcher/_apis/urls/LeagueApiUrls.py +++ b/src/riotwatcher/_apis/urls/LeagueApiUrls.py @@ -12,6 +12,10 @@ class LeagueApiV4Urls(object): grandmaster_by_queue = LeagueV4Endpoint("/grandmasterleagues/by-queue/{queue}") by_id = LeagueV4Endpoint("/leagues/{league_id}") master_by_queue = LeagueV4Endpoint("/masterleagues/by-queue/{queue}") + by_summoner = LeagueV4Endpoint("/entries/by-summoner/{encrypted_summoner_id}") + entries = LeagueV4Endpoint("/entries/{queue}/{tier}/{division}") + + # deprecated positions_by_summoner = LeagueV4Endpoint( "/positions/by-summoner/{encrypted_summoner_id}" )
pseudonym117/Riot-Watcher
4ce2587aad465e93ab920aaac0c60b17e70b433a
diff --git a/tests/_apis/test_LeagueApiV4.py b/tests/_apis/test_LeagueApiV4.py index 02120b6..5acaaa0 100644 --- a/tests/_apis/test_LeagueApiV4.py +++ b/tests/_apis/test_LeagueApiV4.py @@ -104,6 +104,54 @@ class TestLeagueApiV4(object): assert ret is expected_return + def test_by_summoner(self): + mock_base_api = MagicMock() + expected_return = object() + mock_base_api.raw_request.return_value = expected_return + + league = LeagueApiV4(mock_base_api) + region = "fdsga" + encrypted_summoner_id = "enc_summoner_1" + + ret = league.by_summoner(region, encrypted_summoner_id) + + mock_base_api.raw_request.assert_called_once_with( + LeagueApiV4.__name__, + league.by_summoner.__name__, + region, + "https://{region}.api.riotgames.com/lol/league/v4/entries/by-summoner/{encrypted_summonerI_id}".format( + region=region, encrypted_summonerI_id=encrypted_summoner_id + ), + {}, + ) + + assert ret is expected_return + + def test_entries(self): + mock_base_api = MagicMock() + expected_return = object() + mock_base_api.raw_request.return_value = expected_return + + league = LeagueApiV4(mock_base_api) + region = "hfhafg" + queue = "yolo_q" + tier = "wood" + division = "VI" + + ret = league.entries(region, queue, tier, division) + + mock_base_api.raw_request.assert_called_once_with( + LeagueApiV4.__name__, + league.entries.__name__, + region, + "https://{region}.api.riotgames.com/lol/league/v4/entries/{queue}/{tier}/{division}".format( + region=region, queue=queue, tier=tier, division=division + ), + {}, + ) + + assert ret is expected_return + def test_positions_by_summoner(self): mock_base_api = MagicMock() expected_return = object() diff --git a/tests/integration/test_LeagueApiV4.py b/tests/integration/test_LeagueApiV4.py index f3a8f30..bc903ee 100644 --- a/tests/integration/test_LeagueApiV4.py +++ b/tests/integration/test_LeagueApiV4.py @@ -90,6 +90,43 @@ class TestLeagueApiV4(object): headers={"X-Riot-Token": mock_context_v4.api_key}, ) + @pytest.mark.parametrize( + "encrypted_summoner_id", + ["50", "424299938281", "9999999999999999999999", "rtbf12345"], + ) + def test_by_summoner(self, mock_context_v4, region, encrypted_summoner_id): + actual_response = mock_context_v4.watcher.league.by_summoner( + region, encrypted_summoner_id + ) + + assert mock_context_v4.expected_response == actual_response + mock_context_v4.get.assert_called_once_with( + "https://{region}.api.riotgames.com/lol/league/v4/entries/by-summoner/{encrypted_summoner_id}".format( + region=region, encrypted_summoner_id=encrypted_summoner_id + ), + params={}, + headers={"X-Riot-Token": mock_context_v4.api_key}, + ) + + @pytest.mark.parametrize( + "queue", ["RANKED_SOLO_5x5", "RANKED_FLEX_SR", "RANKED_FLEX_TT"] + ) + @pytest.mark.parametrize("tier", ["IRON", "SILVER", "DIAMOND"]) + @pytest.mark.parametrize("division", ["I", "IV"]) + def test_entries(self, mock_context_v4, region, queue, tier, division): + actual_response = mock_context_v4.watcher.league.entries( + region, queue, tier, division + ) + + assert mock_context_v4.expected_response == actual_response + mock_context_v4.get.assert_called_once_with( + "https://{region}.api.riotgames.com/lol/league/v4/entries/{queue}/{tier}/{division}".format( + region=region, queue=queue, tier=tier, division=division + ), + params={}, + headers={"X-Riot-Token": mock_context_v4.api_key}, + ) + @pytest.mark.parametrize( "encrypted_summoner_id", ["50", "424299938281", "9999999999999999999999", "rtbf12345"],
Positional Ranking Deprecation Riot's API team [just announced](https://www.riotgames.com/en/DevRel/riot-api-update-190417) that positional ranking endpoints have been deprecated and will be removed on Monday, June 17th, meaning there are changes to the `league-v4` API. These endpoints are being removed: - `/lol/league/v4/positional-rank-queues` - `/lol/league/v4/positions/by-summoner/{encryptedSummonerId}` - `/lol/league/v4/positions/{positionalQueue}/{tier}/{division}/{position}/{page}` And these are being added: - `/lol/league/v4/entries/by-summoner/{encryptedSummonerId}` - `/lol/league/v4/entries/{queue}/{tier}/{division}` Unfortunately, I don't currently have the bandwidth to make a PR for this myself, but I hope that by posting this early on, someone will be able to pick up this issue! 😓
0.0
4ce2587aad465e93ab920aaac0c60b17e70b433a
[ "tests/_apis/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner", "tests/_apis/test_LeagueApiV4.py::TestLeagueApiV4::test_entries", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[50-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[424299938281-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[9999999999999999999999-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_summoner[rtbf12345-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_SOLO_5x5-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_SR-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-IRON-RANKED_FLEX_TT-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_SOLO_5x5-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_SR-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-SILVER-RANKED_FLEX_TT-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_SOLO_5x5-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_SR-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[I-DIAMOND-RANKED_FLEX_TT-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_SOLO_5x5-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_SR-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-IRON-RANKED_FLEX_TT-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_SOLO_5x5-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_SR-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-SILVER-RANKED_FLEX_TT-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_SOLO_5x5-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_SR-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_entries[IV-DIAMOND-RANKED_FLEX_TT-pbe1]" ]
[ "tests/_apis/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue", "tests/_apis/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue", "tests/_apis/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue", "tests/_apis/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id", "tests/_apis/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_SOLO_5x5-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_SR-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_challenger_by_queue[RANKED_FLEX_TT-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_SOLO_5x5-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_SR-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_grandmaster_by_queue[RANKED_FLEX_TT-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_SOLO_5x5-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_SR-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_masters_by_queue[RANKED_FLEX_TT-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[1-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[500-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_by_id[99999999999999-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[50-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[424299938281-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[9999999999999999999999-pbe1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-br1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-eun1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-euw1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-jp1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-kr]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-la1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-la2]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-na]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-na1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-oc1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-tr1]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-ru]", "tests/integration/test_LeagueApiV4.py::TestLeagueApiV4::test_positions_by_summoner[rtbf12345-pbe1]" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2019-04-19 06:17:35+00:00
mit
4,694
pseudonym117__Riot-Watcher-177
diff --git a/README.rst b/README.rst index bfbc117..98cdd27 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -RiotWatcher v3.1.1 +RiotWatcher v3.1.2 ================== |pypi| |docs| |coverage| |lgmt| |black| @@ -7,7 +7,7 @@ Check for full (read: slightly better) documentation `here <http://riot-watcher. RiotWatcher is a thin wrapper on top of the `Riot Games API for League of Legends <https://developer.riotgames.com/>`__. All public methods as -of 10/3/2020 are supported in full. +of 7/4/2021 are supported in full. RiotWatcher by default supports a naive rate limiter. This rate limiter will try to stop you from making too many requests, and in a single threaded test @@ -84,6 +84,42 @@ raised as HTTPError exceptions from the Requests library. else: raise +MatchApiV5 +---------- + +As of 7/4/2021, both the v4 and v5 versions of the Match API are supported by Riot. As such, RiotWatcher provides a +method to use both. By default, the v4 API will be used for backwards compatibility. + +To use the v5 API by default, use the following to initialize your LolWatcher instance: + +.. code:: python + + from riotwatcher import LolWatcher + + lol_watcher = LolWatcher('<your-api-key>', default_default_match_v5=True) + + # example call + matchlist = lol_watcher.match.matchlist_by_puuid('AMERICAS', 'fake-puuid') + +To explicitly use v4 or v5 during the deprecation period, you can use the following properties: + +.. code:: python + + from riotwatcher import LolWatcher + + lol_watcher = LolWatcher('<your-api-key>') + + # use v5 explicitly + matchlist = lol_watcher.match_v5.matchlist_by_puuid('AMERICAS', 'fake-puuid') + + # use v4 explicitly + old_matchlist = lol_watcher.match_v4.matchlist_by_account('na1', 'fake-account-id') + +Note: this will not be supported after v4 is completely deprecated! Both match_v4 and match_v5 properties will be removed, +and the change will happen with a minor version increase. If you desire seamless backwards compatibility, do not use these +properies. + + Use with kernel --------------- @@ -113,11 +149,15 @@ Rate limiter has some race conditions when used concurrently. Changelog --------- -v3.1.1 - TBD +v3.1.2 - 7/4/2021 ~~~~~~~~~~~~ +Add support for LoL MatchAPI v5 + +v3.1.1 - 10/4/2020 +~~~~~~~~~~~~~~~~~~ Add support for Valorant recent match API. -Add support for LoR MatchAPI. +Add support for LoR MatchAPI. v3.1.0 - 9/1/2020 ~~~~~~~~~~~~~~~~~ diff --git a/docs/index.rst b/docs/index.rst index db800ed..a35cdb6 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -4,7 +4,7 @@ Welcome to RiotWatcher's documentation! RiotWatcher is a thin wrapper on top of the `Riot Games API for League of Legends <https://developer.riotgames.com/>`__. All public methods as -of 10/3/2020 are supported in full. +of 7/4/2021 are supported in full. RiotWatcher by default supports a naive rate limiter. This rate limiter will try to stop you from making too many requests, and in a single threaded test @@ -80,6 +80,41 @@ raised as HTTPError exceptions from the Requests library. else: raise +MatchApiV5 +---------- + +As of 7/4/2021, both the v4 and v5 versions of the Match API are supported by Riot. As such, RiotWatcher provides a +method to use both. By default, the v4 API will be used for backwards compatibility. + +To use the v5 API by default, use the following to initialize your LolWatcher instance: + +.. code:: python + + from riotwatcher import LolWatcher + + lol_watcher = LolWatcher('<your-api-key>', default_default_match_v5=True) + + # example call + matchlist = lol_watcher.match.matchlist_by_puuid('AMERICAS', 'fake-puuid') + +To explicitly use v4 or v5 during the deprecation period, you can use the following properties: + +.. code:: python + + from riotwatcher import LolWatcher + + lol_watcher = LolWatcher('<your-api-key>') + + # use v5 explicitly + matchlist = lol_watcher.match_v5.matchlist_by_puuid('AMERICAS', 'fake-puuid') + + # use v4 explicitly + old_matchlist = lol_watcher.match_v4.matchlist_by_account('na1', 'fake-account-id') + +Note: this will not be supported after v4 is completely deprecated! Both match_v4 and match_v5 properties will be removed, +and the change will happen with a minor version increase. If you desire seamless backwards compatibility, do not use these +properies. + Use with kernel --------------- diff --git a/docs/riotwatcher/LeagueOfLegends/MatchApiV5.rst b/docs/riotwatcher/LeagueOfLegends/MatchApiV5.rst new file mode 100644 index 0000000..f9bfce4 --- /dev/null +++ b/docs/riotwatcher/LeagueOfLegends/MatchApiV5.rst @@ -0,0 +1,8 @@ +MatchApiV4 +========== + +.. py:currentmodule:: riotwatcher + +.. autoclass:: riotwatcher._apis.league_of_legends.MatchApiV5 + :members: + :undoc-members: diff --git a/docs/riotwatcher/LeagueOfLegends/index.rst b/docs/riotwatcher/LeagueOfLegends/index.rst index 17b010c..aa811f9 100644 --- a/docs/riotwatcher/LeagueOfLegends/index.rst +++ b/docs/riotwatcher/LeagueOfLegends/index.rst @@ -21,6 +21,7 @@ All APIs LeagueApiV4.rst LolStatusApiV3.rst MatchApiV4.rst + MatchApiV5.rst SpectatorApiV4.rst SummonerApiV4.rst ThirdPartyCodeApiV4.rst diff --git a/src/riotwatcher/LolWatcher.py b/src/riotwatcher/LolWatcher.py index 0be0016..e3fa631 100644 --- a/src/riotwatcher/LolWatcher.py +++ b/src/riotwatcher/LolWatcher.py @@ -1,3 +1,4 @@ +from typing import Union from .Deserializer import Deserializer from .RateLimiter import RateLimiter @@ -24,7 +25,7 @@ from ._apis.league_of_legends import ( SpectatorApiV4, SummonerApiV4, MatchApiV5, - ThirdPartyCodeApiV4, + ThirdPartyCodeApiV4, ) @@ -40,6 +41,7 @@ class LolWatcher: kernel_url: str = None, rate_limiter: RateLimiter = BasicRateLimiter(), deserializer: Deserializer = DictionaryDeserializer(), + default_match_v5: bool = False, ): """ Initialize a new instance of the RiotWatcher class. @@ -88,13 +90,13 @@ class LolWatcher: self._clash = ClashApiV1(self._base_api) self._champion_mastery = ChampionMasteryApiV4(self._base_api) self._league = LeagueApiV4(self._base_api) - self._match = MatchApiV4(self._base_api) + self._match_v4 = MatchApiV4(self._base_api) + self._match_v5 = MatchApiV5(self._base_api) self._spectator = SpectatorApiV4(self._base_api) self._summoner = SummonerApiV4(self._base_api) - - self._matchv5 = MatchApiV5(self._base_api) - - self._third_party_code = ThirdPartyCodeApiV4(self._base_api) + self._third_party_code = ThirdPartyCodeApiV4(self._base_api) + + self._match = self._match_v5 if default_match_v5 else self._match_v4 # todo: tournament-stub # todo: tournament @@ -144,14 +146,34 @@ class LolWatcher: return self._lol_status @property - def match(self) -> MatchApiV4: + def match(self) -> Union[MatchApiV4, MatchApiV5]: """ Interface to the Match Endpoint + :rtype: league_of_legends.MatchApiV5 + """ + return self._match + + @property + def match_v4(self) -> MatchApiV4: + """ + Temporary explicit interface to match-v4 endpoint. + Will be removed when matchv4 is deprecated. + :rtype: league_of_legends.MatchApiV4 """ return self._match - + + @property + def match_v5(self) -> MatchApiV5: + """ + Temporary explicit interface to match-v5 endpoint. + Will be removed when matchv4 is deprecated. + + :rtype: league_of_legends.MatchApiV5 + """ + return self._match_v5 + @property def spectator(self) -> SpectatorApiV4: """ @@ -178,15 +200,6 @@ class LolWatcher: :rtype: league_of_legends.SummonerApiV4 """ return self._summoner - - @property - def matchv5(self) -> MatchApiV5: - """ - Interface to the Match Endpoint - - :rtype: league_of_legends.MatchApiV5 - """ - return self._matchv5 @property def third_party_code(self) -> ThirdPartyCodeApiV4: @@ -195,4 +208,4 @@ class LolWatcher: :rtype: league_of_legends.ThirdPartyCodeApiV4 """ - return self._third_party_code + return self._third_party_code diff --git a/src/riotwatcher/__version__.py b/src/riotwatcher/__version__.py index be3c421..af847c3 100644 --- a/src/riotwatcher/__version__.py +++ b/src/riotwatcher/__version__.py @@ -1,3 +1,3 @@ -__version__ = "3.1.1" +__version__ = "3.1.2" __author__ = "pseudonym117" __title__ = "RiotWatcher"
pseudonym117/Riot-Watcher
f07a035a4379c4ec8c1fece332582d61ad2ecc1f
diff --git a/tests/integration/league_of_legends/test_MatchApiV4.py b/tests/integration/league_of_legends/test_MatchApiV4.py index e9cdcd5..4a2b02e 100644 --- a/tests/integration/league_of_legends/test_MatchApiV4.py +++ b/tests/integration/league_of_legends/test_MatchApiV4.py @@ -24,7 +24,7 @@ import pytest class TestMatchApiV4: @pytest.mark.parametrize("match_id", [12345, 54321, 2, 222222222222222222222]) def test_by_id(self, lol_context, region, match_id): - actual_response = lol_context.watcher.match.by_id(region, match_id) + actual_response = lol_context.watcher.match_v4.by_id(region, match_id) lol_context.verify_api_call( region, f"/lol/match/v4/matches/{match_id}", {}, actual_response, @@ -56,7 +56,7 @@ class TestMatchApiV4: begin_time, end_time = begin_end_time begin_index, end_index = begin_end_index - actual_response = lol_context.watcher.match.matchlist_by_account( + actual_response = lol_context.watcher.match_v4.matchlist_by_account( region, encrypted_account_id, queue=queue, @@ -93,7 +93,9 @@ class TestMatchApiV4: @pytest.mark.parametrize("match_id", [0, 54321, 3232323232323223]) def test_timeline_by_match(self, lol_context, region, match_id): - actual_response = lol_context.watcher.match.timeline_by_match(region, match_id) + actual_response = lol_context.watcher.match_v4.timeline_by_match( + region, match_id + ) lol_context.verify_api_call( region, f"/lol/match/v4/timelines/by-match/{match_id}", {}, actual_response, diff --git a/tests/integration/league_of_legends/test_MatchApiV5.py b/tests/integration/league_of_legends/test_MatchApiV5.py index 952b614..4f6114c 100644 --- a/tests/integration/league_of_legends/test_MatchApiV5.py +++ b/tests/integration/league_of_legends/test_MatchApiV5.py @@ -4,17 +4,14 @@ import pytest @pytest.mark.lol @pytest.mark.integration @pytest.mark.parametrize( - "region", - [ - "EUROPE", - "AMERICAS", - "ASIA", - ], + "region", ["EUROPE", "AMERICAS", "ASIA",], ) class TestMatchApiV5: - @pytest.mark.parametrize("match_id", ["EUW1_12345", "EUW1_54321", "EUW1_1", "EUW_1222222222222222222222"]) + @pytest.mark.parametrize( + "match_id", ["EUW1_12345", "EUW1_54321", "EUW1_1", "EUW_1222222222222222222222"] + ) def test_by_id(self, lol_context, region, match_id): - actual_response = lol_context.watcher.matchv5.by_id(region, match_id) + actual_response = lol_context.watcher.match_v5.by_id(region, match_id) lol_context.verify_api_call( region, f"/lol/match/v5/matches/{match_id}", {}, actual_response, @@ -22,28 +19,20 @@ class TestMatchApiV5: @pytest.mark.parametrize("puuid", ["12345", "3333333333333333333"]) @pytest.mark.parametrize("count", [None, 20]) - @pytest.mark.parametrize("start", [None, 0]) + @pytest.mark.parametrize("start", [None, 0]) def test_matchlist_by_account( - self, - lol_context, - region, - puuid, - start, - count, - ): - - actual_response = lol_context.watcher.matchv5.matchlist_by_puuid( - region, - puuid, - start=start, - count=count, + self, lol_context, region, puuid, start, count, + ): + + actual_response = lol_context.watcher.match_v5.matchlist_by_puuid( + region, puuid, start=start, count=count, ) expected_params = {} if count is not None: expected_params["count"] = count if start is not None: - expected_params["start"] = start + expected_params["start"] = start lol_context.verify_api_call( region, @@ -52,9 +41,13 @@ class TestMatchApiV5: actual_response, ) - @pytest.mark.parametrize("match_id", ["EUW1_12345", "EUW1_54321", "EUW1_1", "EUW_1222222222222222222222"]) + @pytest.mark.parametrize( + "match_id", ["EUW1_12345", "EUW1_54321", "EUW1_1", "EUW_1222222222222222222222"] + ) def test_timeline_by_match(self, lol_context, region, match_id): - actual_response = lol_context.watcher.matchv5.timeline_by_match(region, match_id) + actual_response = lol_context.watcher.match_v5.timeline_by_match( + region, match_id + ) lol_context.verify_api_call( region, f"/lol/match/v5/matches/{match_id}/timeline", {}, actual_response, diff --git a/tests/test_LolWatcher.py b/tests/test_LolWatcher.py index fa30ab5..2c011c4 100644 --- a/tests/test_LolWatcher.py +++ b/tests/test_LolWatcher.py @@ -1,6 +1,7 @@ import pytest from riotwatcher import LolWatcher +from riotwatcher._apis.league_of_legends import MatchApiV4, MatchApiV5 @pytest.mark.lol @@ -18,3 +19,15 @@ class TestLolWatcher: def test_allows_kernel_url(self): LolWatcher(kernel_url="https://fake-kernel-server") + + def test_defaults_match_v4(self): + watcher = LolWatcher(api_key="RGAPI-this-is-a-fake") + assert isinstance(watcher.match, MatchApiV4) + + def test_uses_match_v4_when_false(self): + watcher = LolWatcher(api_key="RGAPI-this-is-a-fake", default_match_v5=False) + assert isinstance(watcher.match, MatchApiV4) + + def test_uses_match_v5_when_true(self): + watcher = LolWatcher(api_key="RGAPI-this-is-a-fake", default_match_v5=True) + assert isinstance(watcher.match, MatchApiV5)
Match v5 support? We're making match-v5 available on Development API keys. Production access will follow in the coming weeks/month. We'll be deprecating match-v4 on Monday, June 14th. This begins our typical 60 day deprecation period. https://riot.com/3g7BoEl
0.0
f07a035a4379c4ec8c1fece332582d61ad2ecc1f
[ "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-54321-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-2-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[None-222222222222222222222-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-54321-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-2-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_by_id[https://kernel-proxy:8080-222222222222222222222-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end0-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end1-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-None-begin_end2-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end0-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end1-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-None-season1-begin_end2-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end0-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end1-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-None-begin_end2-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end0-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end1-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[None-champion1-season1-begin_end2-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end0-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end1-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-None-begin_end2-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end0-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end1-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-None-season1-begin_end2-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end0-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end1-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-None-begin_end2-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end0-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end1-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-None-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-12345-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_matchlist_by_account[https://kernel-proxy:8080-champion1-season1-begin_end2-queue1-3333333333333333333-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-0-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-54321-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[None-3232323232323223-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-0-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-54321-pbe1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-br1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-eun1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-euw1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-jp1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-kr]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-la1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-la2]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-na]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-na1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-oc1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-tr1]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-ru]", "tests/integration/league_of_legends/test_MatchApiV4.py::TestMatchApiV4::test_timeline_by_match[https://kernel-proxy:8080-3232323232323223-pbe1]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW1_12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW1_12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW1_12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW1_54321-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW1_54321-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW1_54321-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW1_1-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW1_1-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW1_1-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW_1222222222222222222222-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW_1222222222222222222222-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[None-EUW_1222222222222222222222-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW1_12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW1_12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW1_12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW1_54321-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW1_54321-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW1_54321-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW1_1-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW1_1-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW1_1-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW_1222222222222222222222-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW_1222222222222222222222-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_by_id[https://kernel-proxy:8080-EUW_1222222222222222222222-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-None-12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-None-12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-None-12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-None-3333333333333333333-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-None-3333333333333333333-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-None-3333333333333333333-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-20-12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-20-12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-20-12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-20-3333333333333333333-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-20-3333333333333333333-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-None-20-3333333333333333333-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-None-12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-None-12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-None-12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-None-3333333333333333333-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-None-3333333333333333333-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-None-3333333333333333333-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-20-12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-20-12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-20-12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-20-3333333333333333333-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-20-3333333333333333333-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[None-0-20-3333333333333333333-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-None-12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-None-12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-None-12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-None-3333333333333333333-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-None-3333333333333333333-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-None-3333333333333333333-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-20-12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-20-12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-20-12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-20-3333333333333333333-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-20-3333333333333333333-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-None-20-3333333333333333333-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-None-12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-None-12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-None-12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-None-3333333333333333333-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-None-3333333333333333333-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-None-3333333333333333333-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-20-12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-20-12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-20-12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-20-3333333333333333333-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-20-3333333333333333333-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_matchlist_by_account[https://kernel-proxy:8080-0-20-3333333333333333333-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW1_12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW1_12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW1_12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW1_54321-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW1_54321-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW1_54321-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW1_1-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW1_1-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW1_1-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW_1222222222222222222222-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW_1222222222222222222222-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[None-EUW_1222222222222222222222-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW1_12345-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW1_12345-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW1_12345-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW1_54321-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW1_54321-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW1_54321-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW1_1-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW1_1-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW1_1-ASIA]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW_1222222222222222222222-EUROPE]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW_1222222222222222222222-AMERICAS]", "tests/integration/league_of_legends/test_MatchApiV5.py::TestMatchApiV5::test_timeline_by_match[https://kernel-proxy:8080-EUW_1222222222222222222222-ASIA]", "tests/test_LolWatcher.py::TestLolWatcher::test_uses_match_v4_when_false", "tests/test_LolWatcher.py::TestLolWatcher::test_uses_match_v5_when_true" ]
[ "tests/test_LolWatcher.py::TestLolWatcher::test_require_api_key_or_kernel", "tests/test_LolWatcher.py::TestLolWatcher::test_allows_positional_api_key", "tests/test_LolWatcher.py::TestLolWatcher::test_allows_keyword_api_key", "tests/test_LolWatcher.py::TestLolWatcher::test_allows_kernel_url", "tests/test_LolWatcher.py::TestLolWatcher::test_defaults_match_v4" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_hyperlinks", "has_added_files", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2021-07-04 05:49:34+00:00
mit
4,695
pseudonym117__Riot-Watcher-236
diff --git a/src/riotwatcher/_apis/league_of_legends/ChampionMasteryApiV4.py b/src/riotwatcher/_apis/league_of_legends/ChampionMasteryApiV4.py index d86dc7f..5f5d2e3 100644 --- a/src/riotwatcher/_apis/league_of_legends/ChampionMasteryApiV4.py +++ b/src/riotwatcher/_apis/league_of_legends/ChampionMasteryApiV4.py @@ -18,60 +18,75 @@ class ChampionMasteryApiV4(NamedEndpoint): """ super().__init__(base_api, self.__class__.__name__) - def by_summoner(self, region: str, encrypted_summoner_id: str): + def by_puuid(self, region: str, puuid: str): """ Get all champion mastery entries. - :param string region: the region to execute this request on - :param string encrypted_summoner_id: Summoner ID associated with the player + :param string region: the region to execute this request on + :param string puuid: PUUID associated with the player :returns: List[ChampionMasteryDTO]: This object contains a list of Champion Mastery information for player and champion combination. """ return self._request_endpoint( - self.by_summoner.__name__, + self.by_puuid.__name__, region, - ChampionMasteryApiV4Urls.by_summoner, - encrypted_summoner_id=encrypted_summoner_id, + ChampionMasteryApiV4Urls.by_puuid, + puuid=puuid, ) - def by_summoner_by_champion( - self, region: str, encrypted_summoner_id: str, champion_id: int - ): + def by_puuid_by_champion(self, region: str, puuid: str, champion_id: int): """ Get a champion mastery by player ID and champion ID. - :param string region: the region to execute this - request on - :param string encrypted_summoner_id: Summoner ID associated with the player - :param long champion_id: Champion ID to retrieve Champion - Mastery for + :param string region: the region to execute this request on + :param string puuid: PUUID associated with the player + :param long champion_id: Champion ID to retrieve Champion Mastery for :returns: ChampionMasteryDTO: This object contains single Champion Mastery information for player and champion combination. """ return self._request_endpoint( - self.by_summoner_by_champion.__name__, + self.by_puuid_by_champion.__name__, region, - ChampionMasteryApiV4Urls.by_summoner_by_champion, - encrypted_summoner_id=encrypted_summoner_id, + ChampionMasteryApiV4Urls.by_puuid_by_champion, + puuid=puuid, champion_id=champion_id, ) - def scores_by_summoner(self, region: str, encrypted_summoner_id: str): + def top_by_puuid(self, region: str, puuid: str, count: int = None): + """ + Get specified number of top champion mastery entries sorted by number of champion + points descending. + + :param string region: the region to execute this request on + :param string puuid: PUUID associated with the player + :param int count: Number of entries to retrieve, defaults to 3. + + :returns: List[ChampionMasteryDto] + """ + return self._request_endpoint( + self.top_by_puuid.__name__, + region, + ChampionMasteryApiV4Urls.top_by_puuid, + puuid=puuid, + count=count, + ) + + def scores_by_puuid(self, region: str, puuid: str): """ Get a player's total champion mastery score, which is the sum of individual champion mastery levels - :param string region: the region to execute this request on - :param string encrypted_summoner_id: Summoner ID associated with the player + :param string region: the region to execute this request on + :param string puuid: PUUID of the player :returns: int """ return self._request_endpoint( - self.scores_by_summoner.__name__, + self.scores_by_puuid.__name__, region, - ChampionMasteryApiV4Urls.scores_by_summoner, - encrypted_summoner_id=encrypted_summoner_id, + ChampionMasteryApiV4Urls.scores_by_puuid, + puuid=puuid, ) diff --git a/src/riotwatcher/_apis/league_of_legends/urls/ChampionMasteryApiUrls.py b/src/riotwatcher/_apis/league_of_legends/urls/ChampionMasteryApiUrls.py index 928b6a8..570b4f9 100644 --- a/src/riotwatcher/_apis/league_of_legends/urls/ChampionMasteryApiUrls.py +++ b/src/riotwatcher/_apis/league_of_legends/urls/ChampionMasteryApiUrls.py @@ -8,12 +8,11 @@ class ChampionMasteryV4Endpoint(LeagueEndpoint): class ChampionMasteryApiV4Urls: - by_summoner = ChampionMasteryV4Endpoint( - "/champion-masteries/by-summoner/{encrypted_summoner_id}" + by_puuid = ChampionMasteryV4Endpoint("/champion-masteries/by-puuid/{puuid}") + by_puuid_by_champion = ChampionMasteryV4Endpoint( + "/champion-masteries/by-puuid/{puuid}/by-champion/{champion_id}" ) - by_summoner_by_champion = ChampionMasteryV4Endpoint( - "/champion-masteries/by-summoner/{encrypted_summoner_id}/by-champion/{champion_id}" - ) - scores_by_summoner = ChampionMasteryV4Endpoint( - "/scores/by-summoner/{encrypted_summoner_id}" + top_by_puuid = ChampionMasteryV4Endpoint( + "/champion-masteries/by-puuid/{puuid}/top", count=int ) + scores_by_puuid = ChampionMasteryV4Endpoint("/scores/by-puuid/{puuid}")
pseudonym117/Riot-Watcher
cd913a8fddca64e86b3b8bbc26579383d4b9a111
diff --git a/tests/_apis/league_of_legends/test_ChampionMasteryApiV4.py b/tests/_apis/league_of_legends/test_ChampionMasteryApiV4.py index 37e7b27..6cd9f91 100644 --- a/tests/_apis/league_of_legends/test_ChampionMasteryApiV4.py +++ b/tests/_apis/league_of_legends/test_ChampionMasteryApiV4.py @@ -8,67 +8,108 @@ from riotwatcher._apis.league_of_legends import ChampionMasteryApiV4 @pytest.mark.lol @pytest.mark.unit class TestChampionMasteryApiV4: - def test_by_summoner(self): + def test_by_puuid(self): mock_base_api = MagicMock() expected_return = object() mock_base_api.raw_request.return_value = expected_return mastery = ChampionMasteryApiV4(mock_base_api) - region = "afas" - encrypted_summoner_id = "15462" + region = "sfsfa" + puuid = "15357" - ret = mastery.by_summoner(region, encrypted_summoner_id) + ret = mastery.by_puuid(region, puuid) mock_base_api.raw_request.assert_called_once_with( ChampionMasteryApiV4.__name__, - mastery.by_summoner.__name__, + mastery.by_puuid.__name__, region, - f"https://{region}.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/{encrypted_summoner_id}", + f"https://{region}.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-puuid/{puuid}", {}, ) assert ret is expected_return - def test_summoner_by_champion(self): + def test_by_puuid_by_champion(self): mock_base_api = MagicMock() expected_return = object() mock_base_api.raw_request.return_value = expected_return mastery = ChampionMasteryApiV4(mock_base_api) region = "fsgs" - encrypted_summoner_id = "53526" + puuid = "53526" champion_id = 7 - ret = mastery.by_summoner_by_champion( - region, encrypted_summoner_id, champion_id - ) + ret = mastery.by_puuid_by_champion(region, puuid, champion_id) mock_base_api.raw_request.assert_called_once_with( ChampionMasteryApiV4.__name__, - mastery.by_summoner_by_champion.__name__, + mastery.by_puuid_by_champion.__name__, region, - f"https://{region}.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/{encrypted_summoner_id}/by-champion/{champion_id}", + f"https://{region}.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-puuid/{puuid}/by-champion/{champion_id}", {}, ) assert ret is expected_return - def test_scored_by_summoner(self): + def test_top_by_puuid(self): mock_base_api = MagicMock() expected_return = object() mock_base_api.raw_request.return_value = expected_return mastery = ChampionMasteryApiV4(mock_base_api) - region = "fsgs" - encrypted_summoner_id = "6243" + region = "fdsfs" + puuid = "123415r" + count = 15 + + ret = mastery.top_by_puuid(region, puuid, count=count) + + mock_base_api.raw_request.assert_called_once_with( + ChampionMasteryApiV4.__name__, + mastery.top_by_puuid.__name__, + region, + f"https://{region}.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-puuid/{puuid}/top", + {"count": count}, + ) + + assert ret is expected_return + + def test_top_by_puuid_default_count(self): + mock_base_api = MagicMock() + expected_return = object() + mock_base_api.raw_request.return_value = expected_return + + mastery = ChampionMasteryApiV4(mock_base_api) + region = "fdsfs" + puuid = "123415r" + + ret = mastery.top_by_puuid(region, puuid) + + mock_base_api.raw_request.assert_called_once_with( + ChampionMasteryApiV4.__name__, + mastery.top_by_puuid.__name__, + region, + f"https://{region}.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-puuid/{puuid}/top", + {"count": None}, + ) + + assert ret is expected_return + + def test_scores_by_puuid(self): + mock_base_api = MagicMock() + expected_return = object() + mock_base_api.raw_request.return_value = expected_return + + mastery = ChampionMasteryApiV4(mock_base_api) + region = "fdsfs" + puuid = "123415r" - ret = mastery.scores_by_summoner(region, encrypted_summoner_id) + ret = mastery.scores_by_puuid(region, puuid) mock_base_api.raw_request.assert_called_once_with( ChampionMasteryApiV4.__name__, - mastery.scores_by_summoner.__name__, + mastery.scores_by_puuid.__name__, region, - f"https://{region}.api.riotgames.com/lol/champion-mastery/v4/scores/by-summoner/{encrypted_summoner_id}", + f"https://{region}.api.riotgames.com/lol/champion-mastery/v4/scores/by-puuid/{puuid}", {}, ) diff --git a/tests/integration/league_of_legends/test_ChampionMasteryApiV4.py b/tests/integration/league_of_legends/test_ChampionMasteryApiV4.py index f32ccfb..8de47c0 100644 --- a/tests/integration/league_of_legends/test_ChampionMasteryApiV4.py +++ b/tests/integration/league_of_legends/test_ChampionMasteryApiV4.py @@ -21,43 +21,56 @@ import pytest "pbe1", ], ) [email protected]("encrypted_summoner_id", ["50", "424299938281", "rtbf12345"]) [email protected]("puuid", ["50", "rtbf12345"]) class TestChampionMasteryApiV4(object): - def test_by_summoner(self, lol_context, region, encrypted_summoner_id): - actual_response = lol_context.watcher.champion_mastery.by_summoner( - region, encrypted_summoner_id - ) + def test_by_puuid(self, lol_context, region, puuid): + actual_response = lol_context.watcher.champion_mastery.by_puuid(region, puuid) lol_context.verify_api_call( region, - f"/lol/champion-mastery/v4/champion-masteries/by-summoner/{encrypted_summoner_id}", + f"/lol/champion-mastery/v4/champion-masteries/by-puuid/{puuid}", {}, actual_response, ) @pytest.mark.parametrize("champion_id", [0, 1, 9999999999, 150]) - def test_by_summoner_by_champion( - self, lol_context, region, encrypted_summoner_id, champion_id - ): - actual_response = lol_context.watcher.champion_mastery.by_summoner_by_champion( - region, encrypted_summoner_id, champion_id + def test_by_puuid_by_champion(self, lol_context, region, puuid, champion_id): + actual_response = lol_context.watcher.champion_mastery.by_puuid_by_champion( + region, puuid, champion_id ) lol_context.verify_api_call( region, - f"/lol/champion-mastery/v4/champion-masteries/by-summoner/{encrypted_summoner_id}/by-champion/{champion_id}", + f"/lol/champion-mastery/v4/champion-masteries/by-puuid/{puuid}/by-champion/{champion_id}", {}, actual_response, ) - def test_scores_by_summoner(self, lol_context, region, encrypted_summoner_id): - actual_response = lol_context.watcher.champion_mastery.scores_by_summoner( - region, encrypted_summoner_id + @pytest.mark.parametrize("count", [None, 1, 20]) + def test_top_by_puuid(self, lol_context, region, puuid, count): + params = {} + if count is not None: + params["count"] = count + + actual_response = lol_context.watcher.champion_mastery.top_by_puuid( + region, puuid, **params + ) + + lol_context.verify_api_call( + region, + f"/lol/champion-mastery/v4/champion-masteries/by-puuid/{puuid}/top", + params, + actual_response, + ) + + def test_scores_by_puuid(self, lol_context, region, puuid): + actual_response = lol_context.watcher.champion_mastery.scores_by_puuid( + region, puuid ) lol_context.verify_api_call( region, - f"/lol/champion-mastery/v4/scores/by-summoner/{encrypted_summoner_id}", + f"/lol/champion-mastery/v4/scores/by-puuid/{puuid}", {}, actual_response, )
champion_master is outdated, updated from encrypted_summoner_id to puuid When trying to get champion mastery, it still asks for `encrypted_summoner_id` when the API now asks for `puuid` When running: `lol_watcher.champion_mastery.by_summoner_by_champion('na1', 'b4rpqbmfbERhRH3cDPiPLhN0WW0Azxa8oc8jWEHWqqD7mzs', 105)` I get the error: `HTTPError: 403 Client Error: Forbidden for url: https://na1.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/b4rpqbmfbERhRH3cDPiPLhN0WW0Azxa8oc8jWEHWqqD7mzs/by-champion/105` And after surveying the API it is noted that they updated to puuid (https://developer.riotgames.com/apis#champion-mastery-v4/GET_getChampionMasteryByPUUID) So the correct request would be: `https://na1.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-puuid/` instead of `https://na1.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/`
0.0
cd913a8fddca64e86b3b8bbc26579383d4b9a111
[ "tests/_apis/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid", "tests/_apis/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion", "tests/_apis/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid", "tests/_apis/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid_default_count", "tests/_apis/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[None-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid[https://kernel-proxy:8080-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-0-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-1-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-9999999999-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[None-150-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-0-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-1-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-9999999999-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_by_puuid_by_champion[https://kernel-proxy:8080-150-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-None-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-1-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[None-20-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-None-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-1-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_top_by_puuid[https://kernel-proxy:8080-20-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[None-rtbf12345-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-50-pbe1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-br1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-eun1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-euw1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-jp1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-kr]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-la1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-la2]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-na]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-na1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-oc1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-tr1]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-ru]", "tests/integration/league_of_legends/test_ChampionMasteryApiV4.py::TestChampionMasteryApiV4::test_scores_by_puuid[https://kernel-proxy:8080-rtbf12345-pbe1]" ]
[]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2024-04-09 07:40:21+00:00
mit
4,696
psf__black-2739
diff --git a/CHANGES.md b/CHANGES.md index 4f4c6a2..dc52ca3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,6 +20,8 @@ - Tuple unpacking on `return` and `yield` constructs now implies 3.8+ (#2700) - Unparenthesized tuples on annotated assignments (e.g `values: Tuple[int, ...] = 1, 2, 3`) now implies 3.8+ (#2708) +- Allow setting custom cache directory on all platforms with environment variable + `BLACK_CACHE_DIR` (#2739). - Text coloring added in the final statistics (#2712) - For stubs, one blank line between class attributes and methods is now kept if there's at least one pre-existing blank line (#2736) diff --git a/docs/contributing/reference/reference_functions.rst b/docs/contributing/reference/reference_functions.rst index 4353d1b..01ffe44 100644 --- a/docs/contributing/reference/reference_functions.rst +++ b/docs/contributing/reference/reference_functions.rst @@ -96,6 +96,8 @@ Caching .. autofunction:: black.cache.filter_cached +.. autofunction:: black.cache.get_cache_dir + .. autofunction:: black.cache.get_cache_file .. autofunction:: black.cache.get_cache_info diff --git a/docs/usage_and_configuration/file_collection_and_discovery.md b/docs/usage_and_configuration/file_collection_and_discovery.md index 1f43618..bd90ccc 100644 --- a/docs/usage_and_configuration/file_collection_and_discovery.md +++ b/docs/usage_and_configuration/file_collection_and_discovery.md @@ -22,10 +22,12 @@ run. The file is non-portable. The standard location on common operating systems `file-mode` is an int flag that determines whether the file was formatted as 3.6+ only, as .pyi, and whether string normalization was omitted. -To override the location of these files on macOS or Linux, set the environment variable -`XDG_CACHE_HOME` to your preferred location. For example, if you want to put the cache -in the directory you're running _Black_ from, set `XDG_CACHE_HOME=.cache`. _Black_ will -then write the above files to `.cache/black/<version>/`. +To override the location of these files on all systems, set the environment variable +`BLACK_CACHE_DIR` to the preferred location. Alternatively on macOS and Linux, set +`XDG_CACHE_HOME` to you your preferred location. For example, if you want to put the +cache in the directory you're running _Black_ from, set `BLACK_CACHE_DIR=.cache/black`. +_Black_ will then write the above files to `.cache/black`. Note that `BLACK_CACHE_DIR` +will take precedence over `XDG_CACHE_HOME` if both are set. ## .gitignore diff --git a/src/black/cache.py b/src/black/cache.py index bca7279..552c248 100644 --- a/src/black/cache.py +++ b/src/black/cache.py @@ -20,7 +20,23 @@ CacheInfo = Tuple[Timestamp, FileSize] Cache = Dict[str, CacheInfo] -CACHE_DIR = Path(user_cache_dir("black", version=__version__)) +def get_cache_dir() -> Path: + """Get the cache directory used by black. + + Users can customize this directory on all systems using `BLACK_CACHE_DIR` + environment variable. By default, the cache directory is the user cache directory + under the black application. + + This result is immediately set to a constant `black.cache.CACHE_DIR` as to avoid + repeated calls. + """ + # NOTE: Function mostly exists as a clean way to test getting the cache directory. + default_cache_dir = user_cache_dir("black", version=__version__) + cache_dir = Path(os.environ.get("BLACK_CACHE_DIR", default_cache_dir)) + return cache_dir + + +CACHE_DIR = get_cache_dir() def read_cache(mode: Mode) -> Cache:
psf/black
d24bc4364c6ef2337875be1a5b4e0851adaaf0f6
diff --git a/tests/test_black.py b/tests/test_black.py index fd01425..5596909 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -40,7 +40,7 @@ import black import black.files from black import Feature, TargetVersion from black import re_compile_maybe_verbose as compile_pattern -from black.cache import get_cache_file +from black.cache import get_cache_dir, get_cache_file from black.debug import DebugVisitor from black.output import color_diff, diff from black.report import Report @@ -1601,6 +1601,33 @@ class BlackTestCase(BlackBaseTestCase): class TestCaching: + def test_get_cache_dir( + self, + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, + ) -> None: + # Create multiple cache directories + workspace1 = tmp_path / "ws1" + workspace1.mkdir() + workspace2 = tmp_path / "ws2" + workspace2.mkdir() + + # Force user_cache_dir to use the temporary directory for easier assertions + patch_user_cache_dir = patch( + target="black.cache.user_cache_dir", + autospec=True, + return_value=str(workspace1), + ) + + # If BLACK_CACHE_DIR is not set, use user_cache_dir + monkeypatch.delenv("BLACK_CACHE_DIR", raising=False) + with patch_user_cache_dir: + assert get_cache_dir() == workspace1 + + # If it is set, use the path provided in the env var. + monkeypatch.setenv("BLACK_CACHE_DIR", str(workspace2)) + assert get_cache_dir() == workspace2 + def test_cache_broken_file(self) -> None: mode = DEFAULT_MODE with cache_dir() as workspace:
Custom cache directory to be thread/process safe **Is your feature request related to a problem? Please describe.** The cache files are not thread/process safe. I've checked multiple projects simultaneously in different processes but get permission errors when one process is writing to the cache while another is reading from it. On linux the fix is pretty easy: set a different temp directory for each process using the ``XDG_CACHE_HOME`` environment variable but there is no equivalent for Windows (there's somewhat an equivalent but you need a rather [specific setup](https://github.com/platformdirs/platformdirs/blob/main/src/platformdirs/windows.py#L157-L165) to use the environment variable). **Describe the solution you'd like** The solution that will work for my use case (and I think is the least amount of changes) is to create a custom environment variable that overrides using platformdirs to get the cache directory. Think this could look like: ```python CACHE_DIR = Path(os.environ.get("BLACK_CACHE_DIR", user_cache_dir("black", version=__version__))) if not CACHE_DIR.exists(): raise RuntimeError(f"{CACHE_DIR} does not exist") ``` **Describe alternatives you've considered** 1. Add the command line option to turn off cacheing (as this ticket as #248 asked for) (guess is this more work) 2. Add command line option to set the cache directory (guess is this is more work but not a lot) 3. Make the cache dir thread/process safe (guess is this is more work)
0.0
d24bc4364c6ef2337875be1a5b4e0851adaaf0f6
[ "tests/test_black.py::BlackTestCase::test_assertFormatEqual", "tests/test_black.py::BlackTestCase::test_assert_equivalent_different_asts", "tests/test_black.py::BlackTestCase::test_async_as_identifier", "tests/test_black.py::BlackTestCase::test_bpo_2142_workaround", "tests/test_black.py::BlackTestCase::test_bpo_33660_workaround", "tests/test_black.py::BlackTestCase::test_broken_symlink", "tests/test_black.py::BlackTestCase::test_check_diff_use_together", "tests/test_black.py::BlackTestCase::test_code_option", "tests/test_black.py::BlackTestCase::test_code_option_changed", "tests/test_black.py::BlackTestCase::test_code_option_check", "tests/test_black.py::BlackTestCase::test_code_option_check_changed", "tests/test_black.py::BlackTestCase::test_code_option_color_diff", "tests/test_black.py::BlackTestCase::test_code_option_config", "tests/test_black.py::BlackTestCase::test_code_option_diff", "tests/test_black.py::BlackTestCase::test_code_option_fast", "tests/test_black.py::BlackTestCase::test_code_option_parent_config", "tests/test_black.py::BlackTestCase::test_code_option_safe", "tests/test_black.py::BlackTestCase::test_debug_visitor", "tests/test_black.py::BlackTestCase::test_detect_pos_only_arguments", "tests/test_black.py::BlackTestCase::test_empty_ff", "tests/test_black.py::BlackTestCase::test_endmarker", "tests/test_black.py::BlackTestCase::test_equivalency_ast_parse_failure_includes_error", "tests/test_black.py::BlackTestCase::test_experimental_string_processing_warns", "tests/test_black.py::BlackTestCase::test_expression_diff", "tests/test_black.py::BlackTestCase::test_expression_diff_with_color", "tests/test_black.py::BlackTestCase::test_expression_ff", "tests/test_black.py::BlackTestCase::test_find_project_root", "tests/test_black.py::BlackTestCase::test_find_user_pyproject_toml_linux", "tests/test_black.py::BlackTestCase::test_find_user_pyproject_toml_windows", "tests/test_black.py::BlackTestCase::test_for_handled_unexpected_eof_error", "tests/test_black.py::BlackTestCase::test_format_file_contents", "tests/test_black.py::BlackTestCase::test_get_features_used", "tests/test_black.py::BlackTestCase::test_get_features_used_decorator", "tests/test_black.py::BlackTestCase::test_get_features_used_for_future_flags", "tests/test_black.py::BlackTestCase::test_get_future_imports", "tests/test_black.py::BlackTestCase::test_invalid_cli_regex", "tests/test_black.py::BlackTestCase::test_invalid_config_return_code", "tests/test_black.py::BlackTestCase::test_lib2to3_parse", "tests/test_black.py::BlackTestCase::test_multi_file_force_py36", "tests/test_black.py::BlackTestCase::test_multi_file_force_pyi", "tests/test_black.py::BlackTestCase::test_newline_comment_interaction", "tests/test_black.py::BlackTestCase::test_no_files", "tests/test_black.py::BlackTestCase::test_parse_pyproject_toml", "tests/test_black.py::BlackTestCase::test_pep_572_version_detection", "tests/test_black.py::BlackTestCase::test_pipe_force_py36", "tests/test_black.py::BlackTestCase::test_pipe_force_pyi", "tests/test_black.py::BlackTestCase::test_piping", "tests/test_black.py::BlackTestCase::test_piping_diff", "tests/test_black.py::BlackTestCase::test_piping_diff_with_color", "tests/test_black.py::BlackTestCase::test_preserves_line_endings", "tests/test_black.py::BlackTestCase::test_preserves_line_endings_via_stdin", "tests/test_black.py::BlackTestCase::test_python37", "tests/test_black.py::BlackTestCase::test_read_pyproject_toml", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_and_existing_path", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_empty", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename_ipynb", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename_pyi", "tests/test_black.py::BlackTestCase::test_report_normal", "tests/test_black.py::BlackTestCase::test_report_quiet", "tests/test_black.py::BlackTestCase::test_report_verbose", "tests/test_black.py::BlackTestCase::test_required_version_does_not_match_version", "tests/test_black.py::BlackTestCase::test_required_version_matches_version", "tests/test_black.py::BlackTestCase::test_root_logger_not_used_directly", "tests/test_black.py::BlackTestCase::test_single_file_force_py36", "tests/test_black.py::BlackTestCase::test_single_file_force_pyi", "tests/test_black.py::BlackTestCase::test_skip_magic_trailing_comma", "tests/test_black.py::BlackTestCase::test_string_quotes", "tests/test_black.py::BlackTestCase::test_tab_comment_indentation", "tests/test_black.py::BlackTestCase::test_trailing_comma_optional_parens_stability1_pass2", "tests/test_black.py::BlackTestCase::test_trailing_comma_optional_parens_stability2_pass2", "tests/test_black.py::BlackTestCase::test_trailing_comma_optional_parens_stability3_pass2", "tests/test_black.py::BlackTestCase::test_works_in_mono_process_only_environment", "tests/test_black.py::TestCaching::test_get_cache_dir", "tests/test_black.py::TestCaching::test_cache_broken_file", "tests/test_black.py::TestCaching::test_cache_single_file_already_cached", "tests/test_black.py::TestCaching::test_cache_multiple_files", "tests/test_black.py::TestCaching::test_no_cache_when_writeback_diff[no-color]", "tests/test_black.py::TestCaching::test_no_cache_when_writeback_diff[with-color]", "tests/test_black.py::TestCaching::test_output_locking_when_writeback_diff[no-color]", "tests/test_black.py::TestCaching::test_output_locking_when_writeback_diff[with-color]", "tests/test_black.py::TestCaching::test_no_cache_when_stdin", "tests/test_black.py::TestCaching::test_read_cache_no_cachefile", "tests/test_black.py::TestCaching::test_write_cache_read_cache", "tests/test_black.py::TestCaching::test_filter_cached", "tests/test_black.py::TestCaching::test_write_cache_creates_directory_if_needed", "tests/test_black.py::TestCaching::test_failed_formatting_does_not_get_cached", "tests/test_black.py::TestCaching::test_write_cache_write_fail", "tests/test_black.py::TestCaching::test_read_cache_line_lengths", "tests/test_black.py::TestFileCollection::test_include_exclude", "tests/test_black.py::TestFileCollection::test_gitignore_used_as_default", "tests/test_black.py::TestFileCollection::test_exclude_for_issue_1572", "tests/test_black.py::TestFileCollection::test_gitignore_exclude", "tests/test_black.py::TestFileCollection::test_nested_gitignore", "tests/test_black.py::TestFileCollection::test_invalid_gitignore", "tests/test_black.py::TestFileCollection::test_invalid_nested_gitignore", "tests/test_black.py::TestFileCollection::test_empty_include", "tests/test_black.py::TestFileCollection::test_extend_exclude", "tests/test_black.py::TestFileCollection::test_symlink_out_of_root_directory", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_extend_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_force_exclude" ]
[]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2022-01-01 00:35:51+00:00
mit
4,697
psf__black-2758
diff --git a/CHANGES.md b/CHANGES.md index dc52ca3..634db79 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -36,6 +36,8 @@ Jupyter Notebooks (#2744) - Deprecate `--experimental-string-processing` and move the functionality under `--preview` (#2789) +- Enable Python 3.10+ by default, without any extra need to specify + `--target-version=py310`. (#2758) ### Packaging diff --git a/src/black/parsing.py b/src/black/parsing.py index 6b63368..db48ae4 100644 --- a/src/black/parsing.py +++ b/src/black/parsing.py @@ -42,7 +42,6 @@ except ImportError: ast3 = ast -PY310_HINT: Final = "Consider using --target-version py310 to parse Python 3.10 code." PY2_HINT: Final = "Python 2 support was removed in version 22.0." @@ -58,12 +57,11 @@ def get_grammars(target_versions: Set[TargetVersion]) -> List[Grammar]: pygram.python_grammar_no_print_statement_no_exec_statement_async_keywords, # Python 3.0-3.6 pygram.python_grammar_no_print_statement_no_exec_statement, + # Python 3.10+ + pygram.python_grammar_soft_keywords, ] grammars = [] - if supports_feature(target_versions, Feature.PATTERN_MATCHING): - # Python 3.10+ - grammars.append(pygram.python_grammar_soft_keywords) # If we have to parse both, try to parse async as a keyword first if not supports_feature( target_versions, Feature.ASYNC_IDENTIFIERS @@ -75,6 +73,10 @@ def get_grammars(target_versions: Set[TargetVersion]) -> List[Grammar]: if not supports_feature(target_versions, Feature.ASYNC_KEYWORDS): # Python 3.0-3.6 grammars.append(pygram.python_grammar_no_print_statement_no_exec_statement) + if supports_feature(target_versions, Feature.PATTERN_MATCHING): + # Python 3.10+ + grammars.append(pygram.python_grammar_soft_keywords) + # At least one of the above branches must have been taken, because every Python # version has exactly one of the two 'ASYNC_*' flags return grammars @@ -86,6 +88,7 @@ def lib2to3_parse(src_txt: str, target_versions: Iterable[TargetVersion] = ()) - src_txt += "\n" grammars = get_grammars(set(target_versions)) + errors = {} for grammar in grammars: drv = driver.Driver(grammar) try: @@ -99,20 +102,21 @@ def lib2to3_parse(src_txt: str, target_versions: Iterable[TargetVersion] = ()) - faulty_line = lines[lineno - 1] except IndexError: faulty_line = "<line number missing in source>" - exc = InvalidInput(f"Cannot parse: {lineno}:{column}: {faulty_line}") + errors[grammar.version] = InvalidInput( + f"Cannot parse: {lineno}:{column}: {faulty_line}" + ) except TokenError as te: # In edge cases these are raised; and typically don't have a "faulty_line". lineno, column = te.args[1] - exc = InvalidInput(f"Cannot parse: {lineno}:{column}: {te.args[0]}") + errors[grammar.version] = InvalidInput( + f"Cannot parse: {lineno}:{column}: {te.args[0]}" + ) else: - if pygram.python_grammar_soft_keywords not in grammars and matches_grammar( - src_txt, pygram.python_grammar_soft_keywords - ): - original_msg = exc.args[0] - msg = f"{original_msg}\n{PY310_HINT}" - raise InvalidInput(msg) from None + # Choose the latest version when raising the actual parsing error. + assert len(errors) >= 1 + exc = errors[max(errors)] if matches_grammar(src_txt, pygram.python_grammar) or matches_grammar( src_txt, pygram.python_grammar_no_print_statement diff --git a/src/blib2to3/pgen2/grammar.py b/src/blib2to3/pgen2/grammar.py index 5685107..337a64f 100644 --- a/src/blib2to3/pgen2/grammar.py +++ b/src/blib2to3/pgen2/grammar.py @@ -92,6 +92,7 @@ class Grammar(object): self.soft_keywords: Dict[str, int] = {} self.tokens: Dict[int, int] = {} self.symbol2label: Dict[str, int] = {} + self.version: Tuple[int, int] = (0, 0) self.start = 256 # Python 3.7+ parses async as a keyword, not an identifier self.async_keywords = False @@ -145,6 +146,7 @@ class Grammar(object): new.labels = self.labels[:] new.states = self.states[:] new.start = self.start + new.version = self.version new.async_keywords = self.async_keywords return new diff --git a/src/blib2to3/pygram.py b/src/blib2to3/pygram.py index aa20b81..a3df9be 100644 --- a/src/blib2to3/pygram.py +++ b/src/blib2to3/pygram.py @@ -178,6 +178,8 @@ def initialize(cache_dir: Union[str, "os.PathLike[str]", None] = None) -> None: # Python 2 python_grammar = driver.load_packaged_grammar("blib2to3", _GRAMMAR_FILE, cache_dir) + python_grammar.version = (2, 0) + soft_keywords = python_grammar.soft_keywords.copy() python_grammar.soft_keywords.clear() @@ -191,6 +193,7 @@ def initialize(cache_dir: Union[str, "os.PathLike[str]", None] = None) -> None: python_grammar_no_print_statement_no_exec_statement = python_grammar.copy() del python_grammar_no_print_statement_no_exec_statement.keywords["print"] del python_grammar_no_print_statement_no_exec_statement.keywords["exec"] + python_grammar_no_print_statement_no_exec_statement.version = (3, 0) # Python 3.7+ python_grammar_no_print_statement_no_exec_statement_async_keywords = ( @@ -199,12 +202,14 @@ def initialize(cache_dir: Union[str, "os.PathLike[str]", None] = None) -> None: python_grammar_no_print_statement_no_exec_statement_async_keywords.async_keywords = ( True ) + python_grammar_no_print_statement_no_exec_statement_async_keywords.version = (3, 7) # Python 3.10+ python_grammar_soft_keywords = ( python_grammar_no_print_statement_no_exec_statement_async_keywords.copy() ) python_grammar_soft_keywords.soft_keywords = soft_keywords + python_grammar_soft_keywords.version = (3, 10) pattern_grammar = driver.load_packaged_grammar( "blib2to3", _PATTERN_GRAMMAR_FILE, cache_dir
psf/black
b3b341b44fde044938daa6691fa1064ea240ff96
diff --git a/tests/test_format.py b/tests/test_format.py index 40f225c..3895a09 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -191,6 +191,12 @@ def test_python_310(filename: str) -> None: assert_format(source, expected, mode, minimum_version=(3, 10)) +def test_python_310_without_target_version() -> None: + source, expected = read_data("pattern_matching_simple") + mode = black.Mode() + assert_format(source, expected, mode, minimum_version=(3, 10)) + + def test_patma_invalid() -> None: source, expected = read_data("pattern_matching_invalid") mode = black.Mode(target_versions={black.TargetVersion.PY310}) @@ -200,15 +206,6 @@ def test_patma_invalid() -> None: exc_info.match("Cannot parse: 10:11") -def test_patma_hint() -> None: - source, expected = read_data("pattern_matching_simple") - mode = black.Mode(target_versions={black.TargetVersion.PY39}) - with pytest.raises(black.parsing.InvalidInput) as exc_info: - assert_format(source, expected, mode, minimum_version=(3, 10)) - - exc_info.match(black.parsing.PY310_HINT) - - def test_python_2_hint() -> None: with pytest.raises(black.parsing.InvalidInput) as exc_info: assert_format("print 'daylily'", "print 'daylily'")
Enable pattern matching by default Now that the speed-up PR landed, it should be safe for us to enable pattern matching by default as the last grammar case to try. This would still make us initially test the 3.7+ and 3.0-3.6 grammars first before we try to run with the backtracking.
0.0
b3b341b44fde044938daa6691fa1064ea240ff96
[ "tests/test_format.py::test_python_310_without_target_version" ]
[ "tests/test_format.py::test_simple_format[composition]", "tests/test_format.py::test_python_310[pattern_matching_simple]", "tests/test_format.py::test_pep_572", "tests/test_format.py::test_simple_format[fmtskip3]", "tests/test_format.py::test_simple_format[function_trailing_comma]", "tests/test_format.py::test_docstring_no_string_normalization", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/parse.py]", "tests/test_format.py::test_simple_format[collections]", "tests/test_format.py::test_simple_format[slices]", "tests/test_format.py::test_simple_format[comments2]", "tests/test_format.py::test_preview_format[long_strings]", "tests/test_format.py::test_simple_format[string_prefixes]", "tests/test_format.py::test_simple_format[fmtskip4]", "tests/test_format.py::test_source_is_formatted[src/black/lines.py]", "tests/test_format.py::test_preview_format[percent_precedence]", "tests/test_format.py::test_source_is_formatted[src/black/__main__.py]", "tests/test_format.py::test_preview_format[long_strings__regression]", "tests/test_format.py::test_preview_format[cantfit]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/tokenize.py]", "tests/test_format.py::test_source_is_formatted[src/black/__init__.py]", "tests/test_format.py::test_simple_format[remove_parens]", "tests/test_format.py::test_source_is_formatted[src/black/const.py]", "tests/test_format.py::test_source_is_formatted[src/black_primer/cli.py]", "tests/test_format.py::test_simple_format[comments3]", "tests/test_format.py::test_simple_format[fmtskip]", "tests/test_format.py::test_source_is_formatted[src/black_primer/lib.py]", "tests/test_format.py::test_simple_format[class_blank_parentheses]", "tests/test_format.py::test_simple_format[function]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pytree.py]", "tests/test_format.py::test_source_is_formatted[src/black/numerics.py]", "tests/test_format.py::test_simple_format[fmtskip2]", "tests/test_format.py::test_source_is_formatted[src/black/mode.py]", "tests/test_format.py::test_python_310[pattern_matching_generic]", "tests/test_format.py::test_pep_572_do_not_remove_parens", "tests/test_format.py::test_simple_format[comments5]", "tests/test_format.py::test_simple_format[comments4]", "tests/test_format.py::test_pep_572_newer_syntax[3-10]", "tests/test_format.py::test_python39", "tests/test_format.py::test_simple_format[fmtskip6]", "tests/test_format.py::test_source_is_formatted[src/black/nodes.py]", "tests/test_format.py::test_source_is_formatted[src/black/brackets.py]", "tests/test_format.py::test_source_is_formatted[src/black/rusty.py]", "tests/test_format.py::test_python_310[pattern_matching_extras]", "tests/test_format.py::test_source_is_formatted[src/black/comments.py]", "tests/test_format.py::test_simple_format[import_spacing]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/pgen.py]", "tests/test_format.py::test_preview_format[long_strings__edge_case]", "tests/test_format.py::test_patma_invalid", "tests/test_format.py::test_simple_format[comments]", "tests/test_format.py::test_simple_format[comments6]", "tests/test_format.py::test_python_2_hint", "tests/test_format.py::test_source_is_formatted[src/black/concurrency.py]", "tests/test_format.py::test_simple_format[fmtonoff]", "tests/test_format.py::test_source_is_formatted[src/black/debug.py]", "tests/test_format.py::test_empty", "tests/test_format.py::test_source_is_formatted[src/black/strings.py]", "tests/test_format.py::test_source_is_formatted[src/black/cache.py]", "tests/test_format.py::test_simple_format[comments_non_breaking_space]", "tests/test_format.py::test_long_strings_flag_disabled", "tests/test_format.py::test_source_is_formatted[src/black/files.py]", "tests/test_format.py::test_source_is_formatted[setup.py]", "tests/test_format.py::test_source_is_formatted[tests/util.py]", "tests/test_format.py::test_source_is_formatted[src/blackd/__init__.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/token.py]", "tests/test_format.py::test_simple_format[fmtonoff3]", "tests/test_format.py::test_source_is_formatted[tests/test_blackd.py]", "tests/test_format.py::test_simple_format[empty_lines]", "tests/test_format.py::test_simple_format[composition_no_trailing_comma]", "tests/test_format.py::test_simple_format[tricky_unicode_symbols]", "tests/test_format.py::test_stub", "tests/test_format.py::test_simple_format[bracketmatch]", "tests/test_format.py::test_simple_format[fmtonoff2]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/driver.py]", "tests/test_format.py::test_source_is_formatted[src/black/parsing.py]", "tests/test_format.py::test_simple_format[fmtskip5]", "tests/test_format.py::test_python_310[parenthesized_context_managers]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/literals.py]", "tests/test_format.py::test_source_is_formatted[src/black/linegen.py]", "tests/test_format.py::test_preview_format[comments7]", "tests/test_format.py::test_source_is_formatted[src/black/report.py]", "tests/test_format.py::test_simple_format[docstring]", "tests/test_format.py::test_pep_572_remove_parens", "tests/test_format.py::test_source_is_formatted[tests/optional.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/grammar.py]", "tests/test_format.py::test_source_is_formatted[tests/test_format.py]", "tests/test_format.py::test_simple_format[class_methods_new_line]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pygram.py]", "tests/test_format.py::test_numeric_literals_ignoring_underscores", "tests/test_format.py::test_source_is_formatted[tests/test_primer.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/conv.py]", "tests/test_format.py::test_simple_format[fmtonoff4]", "tests/test_format.py::test_numeric_literals", "tests/test_format.py::test_source_is_formatted[src/black/output.py]", "tests/test_format.py::test_source_is_formatted[tests/test_black.py]", "tests/test_format.py::test_simple_format[beginning_backslash]", "tests/test_format.py::test_simple_format[tupleassign]", "tests/test_format.py::test_pep_570", "tests/test_format.py::test_source_is_formatted[tests/conftest.py]", "tests/test_format.py::test_python_310[pattern_matching_complex]", "tests/test_format.py::test_python_310[pattern_matching_style]", "tests/test_format.py::test_python38", "tests/test_format.py::test_simple_format[fstring]", "tests/test_format.py::test_pep_572_newer_syntax[3-9]", "tests/test_format.py::test_source_is_formatted[src/black/trans.py]", "tests/test_format.py::test_simple_format[expression]", "tests/test_format.py::test_simple_format[function2]", "tests/test_format.py::test_simple_format[comment_after_escaped_newline]" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks", "has_pytest_match_arg" ], "has_test_patch": true, "is_lite": false }
2022-01-10 18:49:16+00:00
mit
4,698
psf__black-2940
diff --git a/CHANGES.md b/CHANGES.md index bb3ccb9..d0faf7c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,8 @@ <!-- Changes that affect Black's preview style --> +- Code cell separators `#%%` are now standardised to `# %%` (#2919) + ### _Blackd_ <!-- Changes to blackd --> diff --git a/docs/the_black_code_style/current_style.md b/docs/the_black_code_style/current_style.md index 0bf5894..d54c7ab 100644 --- a/docs/the_black_code_style/current_style.md +++ b/docs/the_black_code_style/current_style.md @@ -399,16 +399,11 @@ recommended code style for those files is more terse than PEP 8: _Black_ enforces the above rules. There are additional guidelines for formatting `.pyi` file that are not enforced yet but might be in a future version of the formatter: -- all function bodies should be empty (contain `...` instead of the body); -- do not use docstrings; - prefer `...` over `pass`; -- for arguments with a default, use `...` instead of the actual default; - avoid using string literals in type annotations, stub files support forward references natively (like Python 3.7 code with `from __future__ import annotations`); - use variable annotations instead of type comments, even for stubs that target older - versions of Python; -- for arguments that default to `None`, use `Optional[]` explicitly; -- use `float` instead of `Union[int, float]`. + versions of Python. ## Pragmatism diff --git a/src/black/__init__.py b/src/black/__init__.py index c4ec99b..51e31e9 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -1166,7 +1166,7 @@ def _format_str_once(src_contents: str, *, mode: Mode) -> str: else: versions = detect_target_versions(src_node, future_imports=future_imports) - normalize_fmt_off(src_node) + normalize_fmt_off(src_node, preview=mode.preview) lines = LineGenerator(mode=mode) elt = EmptyLineTracker(is_pyi=mode.is_pyi) empty_line = Line(mode=mode) diff --git a/src/black/comments.py b/src/black/comments.py index 28b9117..4553264 100644 --- a/src/black/comments.py +++ b/src/black/comments.py @@ -23,6 +23,8 @@ FMT_SKIP: Final = {"# fmt: skip", "# fmt:skip"} FMT_PASS: Final = {*FMT_OFF, *FMT_SKIP} FMT_ON: Final = {"# fmt: on", "# fmt:on", "# yapf: enable"} +COMMENT_EXCEPTIONS = {True: " !:#'", False: " !:#'%"} + @dataclass class ProtoComment: @@ -42,7 +44,7 @@ class ProtoComment: consumed: int # how many characters of the original leaf's prefix did we consume -def generate_comments(leaf: LN) -> Iterator[Leaf]: +def generate_comments(leaf: LN, *, preview: bool) -> Iterator[Leaf]: """Clean the prefix of the `leaf` and generate comments from it, if any. Comments in lib2to3 are shoved into the whitespace prefix. This happens @@ -61,12 +63,16 @@ def generate_comments(leaf: LN) -> Iterator[Leaf]: Inline comments are emitted as regular token.COMMENT leaves. Standalone are emitted with a fake STANDALONE_COMMENT token identifier. """ - for pc in list_comments(leaf.prefix, is_endmarker=leaf.type == token.ENDMARKER): + for pc in list_comments( + leaf.prefix, is_endmarker=leaf.type == token.ENDMARKER, preview=preview + ): yield Leaf(pc.type, pc.value, prefix="\n" * pc.newlines) @lru_cache(maxsize=4096) -def list_comments(prefix: str, *, is_endmarker: bool) -> List[ProtoComment]: +def list_comments( + prefix: str, *, is_endmarker: bool, preview: bool +) -> List[ProtoComment]: """Return a list of :class:`ProtoComment` objects parsed from the given `prefix`.""" result: List[ProtoComment] = [] if not prefix or "#" not in prefix: @@ -92,7 +98,7 @@ def list_comments(prefix: str, *, is_endmarker: bool) -> List[ProtoComment]: comment_type = token.COMMENT # simple trailing comment else: comment_type = STANDALONE_COMMENT - comment = make_comment(line) + comment = make_comment(line, preview=preview) result.append( ProtoComment( type=comment_type, value=comment, newlines=nlines, consumed=consumed @@ -102,10 +108,10 @@ def list_comments(prefix: str, *, is_endmarker: bool) -> List[ProtoComment]: return result -def make_comment(content: str) -> str: +def make_comment(content: str, *, preview: bool) -> str: """Return a consistently formatted comment from the given `content` string. - All comments (except for "##", "#!", "#:", '#'", "#%%") should have a single + All comments (except for "##", "#!", "#:", '#'") should have a single space between the hash sign and the content. If `content` didn't start with a hash sign, one is provided. @@ -123,26 +129,26 @@ def make_comment(content: str) -> str: and not content.lstrip().startswith("type:") ): content = " " + content[1:] # Replace NBSP by a simple space - if content and content[0] not in " !:#'%": + if content and content[0] not in COMMENT_EXCEPTIONS[preview]: content = " " + content return "#" + content -def normalize_fmt_off(node: Node) -> None: +def normalize_fmt_off(node: Node, *, preview: bool) -> None: """Convert content between `# fmt: off`/`# fmt: on` into standalone comments.""" try_again = True while try_again: - try_again = convert_one_fmt_off_pair(node) + try_again = convert_one_fmt_off_pair(node, preview=preview) -def convert_one_fmt_off_pair(node: Node) -> bool: +def convert_one_fmt_off_pair(node: Node, *, preview: bool) -> bool: """Convert content of a single `# fmt: off`/`# fmt: on` into a standalone comment. Returns True if a pair was converted. """ for leaf in node.leaves(): previous_consumed = 0 - for comment in list_comments(leaf.prefix, is_endmarker=False): + for comment in list_comments(leaf.prefix, is_endmarker=False, preview=preview): if comment.value not in FMT_PASS: previous_consumed = comment.consumed continue @@ -157,7 +163,7 @@ def convert_one_fmt_off_pair(node: Node) -> bool: if comment.value in FMT_SKIP and prev.type in WHITESPACE: continue - ignored_nodes = list(generate_ignored_nodes(leaf, comment)) + ignored_nodes = list(generate_ignored_nodes(leaf, comment, preview=preview)) if not ignored_nodes: continue @@ -197,7 +203,9 @@ def convert_one_fmt_off_pair(node: Node) -> bool: return False -def generate_ignored_nodes(leaf: Leaf, comment: ProtoComment) -> Iterator[LN]: +def generate_ignored_nodes( + leaf: Leaf, comment: ProtoComment, *, preview: bool +) -> Iterator[LN]: """Starting from the container of `leaf`, generate all leaves until `# fmt: on`. If comment is skip, returns leaf only. @@ -221,13 +229,13 @@ def generate_ignored_nodes(leaf: Leaf, comment: ProtoComment) -> Iterator[LN]: yield leaf.parent return while container is not None and container.type != token.ENDMARKER: - if is_fmt_on(container): + if is_fmt_on(container, preview=preview): return # fix for fmt: on in children - if contains_fmt_on_at_column(container, leaf.column): + if contains_fmt_on_at_column(container, leaf.column, preview=preview): for child in container.children: - if contains_fmt_on_at_column(child, leaf.column): + if contains_fmt_on_at_column(child, leaf.column, preview=preview): return yield child else: @@ -235,12 +243,12 @@ def generate_ignored_nodes(leaf: Leaf, comment: ProtoComment) -> Iterator[LN]: container = container.next_sibling -def is_fmt_on(container: LN) -> bool: +def is_fmt_on(container: LN, preview: bool) -> bool: """Determine whether formatting is switched on within a container. Determined by whether the last `# fmt:` comment is `on` or `off`. """ fmt_on = False - for comment in list_comments(container.prefix, is_endmarker=False): + for comment in list_comments(container.prefix, is_endmarker=False, preview=preview): if comment.value in FMT_ON: fmt_on = True elif comment.value in FMT_OFF: @@ -248,7 +256,7 @@ def is_fmt_on(container: LN) -> bool: return fmt_on -def contains_fmt_on_at_column(container: LN, column: int) -> bool: +def contains_fmt_on_at_column(container: LN, column: int, *, preview: bool) -> bool: """Determine if children at a given column have formatting switched on.""" for child in container.children: if ( @@ -257,7 +265,7 @@ def contains_fmt_on_at_column(container: LN, column: int) -> bool: or isinstance(child, Leaf) and child.column == column ): - if is_fmt_on(child): + if is_fmt_on(child, preview=preview): return True return False diff --git a/src/black/linegen.py b/src/black/linegen.py index 4dc242a..79475a8 100644 --- a/src/black/linegen.py +++ b/src/black/linegen.py @@ -72,7 +72,7 @@ class LineGenerator(Visitor[Line]): """Default `visit_*()` implementation. Recurses to children of `node`.""" if isinstance(node, Leaf): any_open_brackets = self.current_line.bracket_tracker.any_open_brackets() - for comment in generate_comments(node): + for comment in generate_comments(node, preview=self.mode.preview): if any_open_brackets: # any comment within brackets is subject to splitting self.current_line.append(comment) @@ -132,7 +132,7 @@ class LineGenerator(Visitor[Line]): `parens` holds a set of string leaf values immediately after which invisible parens should be put. """ - normalize_invisible_parens(node, parens_after=parens) + normalize_invisible_parens(node, parens_after=parens, preview=self.mode.preview) for child in node.children: if is_name_token(child) and child.value in keywords: yield from self.line() @@ -141,7 +141,7 @@ class LineGenerator(Visitor[Line]): def visit_match_case(self, node: Node) -> Iterator[Line]: """Visit either a match or case statement.""" - normalize_invisible_parens(node, parens_after=set()) + normalize_invisible_parens(node, parens_after=set(), preview=self.mode.preview) yield from self.line() for child in node.children: @@ -802,7 +802,9 @@ def normalize_prefix(leaf: Leaf, *, inside_brackets: bool) -> None: leaf.prefix = "" -def normalize_invisible_parens(node: Node, parens_after: Set[str]) -> None: +def normalize_invisible_parens( + node: Node, parens_after: Set[str], *, preview: bool +) -> None: """Make existing optional parentheses invisible or create new ones. `parens_after` is a set of string leaf values immediately after which parens @@ -811,7 +813,7 @@ def normalize_invisible_parens(node: Node, parens_after: Set[str]) -> None: Standardizes on visible parentheses for single-element tuples, and keeps existing visible parentheses for other tuples and generator expressions. """ - for pc in list_comments(node.prefix, is_endmarker=False): + for pc in list_comments(node.prefix, is_endmarker=False, preview=preview): if pc.value in FMT_OFF: # This `node` has a prefix with `# fmt: off`, don't mess with parens. return @@ -820,7 +822,9 @@ def normalize_invisible_parens(node: Node, parens_after: Set[str]) -> None: # Fixes a bug where invisible parens are not properly stripped from # assignment statements that contain type annotations. if isinstance(child, Node) and child.type == syms.annassign: - normalize_invisible_parens(child, parens_after=parens_after) + normalize_invisible_parens( + child, parens_after=parens_after, preview=preview + ) # Add parentheses around long tuple unpacking in assignments. if (
psf/black
fa7f01592b02229ff47f3bcab39a9b7d6c59f07c
diff --git a/tests/data/comments8.py b/tests/data/comments8.py new file mode 100644 index 0000000..a2030c2 --- /dev/null +++ b/tests/data/comments8.py @@ -0,0 +1,15 @@ +# The percent-percent comments are Spyder IDE cells. +# Both `#%%`` and `# %%` are accepted, so `black` standardises +# to the latter. + +#%% +# %% + +# output + +# The percent-percent comments are Spyder IDE cells. +# Both `#%%`` and `# %%` are accepted, so `black` standardises +# to the latter. + +# %% +# %% diff --git a/tests/test_format.py b/tests/test_format.py index 269bbac..667d5c1 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -75,6 +75,7 @@ PREVIEW_CASES: List[str] = [ # string processing "cantfit", "comments7", + "comments8", "long_strings", "long_strings__edge_case", "long_strings__regression",
Future style for stub file docstrings that use C/C++ extensions Hello Black community. I write to you today to discuss the style outlined in the documentation for stub files (Python files meant for typing purposes with a `.pyi` extension). In the _Black Code Style_ section of the documentation there is a section describing future style guidelines for the `.pyi` files: [Typing Stub Files](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#typing-stub-files). **Description** <!-- A clear and concise description of how the style can be improved. --> The point I wish to argue against today is the line: "do not use docstrings". I imagine this is referring to a Python stub file that is providing type hints for another Python file, like so: _add.py_ ```Python def add(a, b): " here's an existing docstring" return a + b ``` _add.pyi_ ```python def add(a: int, b: int) -> int: " here's another stub file docstring" ... ``` In which case, it would make sense to either include the docstring in one file or the other. However, the edge case I wish to bring to your attention is when using C/C++ extensions for Python code. In particular I will discuss the use of [PyBind11](https://pybind11.readthedocs.io/en/stable/basics.html). PyBind11 produces a shared library with a name such as `add.cpython-38-x86_64-linux-gnu.so`, which contains inside it Python objects that you can import as any other Python object. However, modern Intellisense servers like [Pylance](https://github.com/microsoft/pylance-release) do not extract information from binary files by [design](https://github.com/microsoft/pylance-release/issues/70), and therefore you _cannot_ get any documentation from a binary file, be this docstrings or type information. Therefore, a stub file can be used to make up for the design limitation, but you need to include docstrings in the stub file in order to get useful information about a function written with PyBind11. _add_pybind11.py_ ```python # import the add function from a PyBind11 produced binary import add from _add_pybind11 # the above will generate no intellisense due to the design limitation of tools like pylance ``` _add_pybind11.pyi_ ```python # define the docstring and type information for the C/C++ bound object def add(a: int, b: int) -> int: " This function was generated by pybind11 and therefore needs a stub file to use with intellisense" ... ``` **Conclusion** I'd like to offer the example of using stub files with binary libraries, such as those produced by PyBind11, as a reason to allow docstrings in stub files in future versions of the formatter. This can be with a flag or configuration, but rest assured having Black delete my docstrings for my PyBind11 objects would cause headaches. <!-- Add any other context about the problem here. --> ![image](https://user-images.githubusercontent.com/29968424/159010748-6203be64-527a-4d0b-a2f7-401da9023014.png)
0.0
fa7f01592b02229ff47f3bcab39a9b7d6c59f07c
[ "tests/test_format.py::test_preview_format[comments8]" ]
[ "tests/test_format.py::test_simple_format[attribute_access_on_number_literals]", "tests/test_format.py::test_simple_format[beginning_backslash]", "tests/test_format.py::test_simple_format[bracketmatch]", "tests/test_format.py::test_simple_format[class_blank_parentheses]", "tests/test_format.py::test_simple_format[class_methods_new_line]", "tests/test_format.py::test_simple_format[collections]", "tests/test_format.py::test_simple_format[comments]", "tests/test_format.py::test_simple_format[comments2]", "tests/test_format.py::test_simple_format[comments3]", "tests/test_format.py::test_simple_format[comments4]", "tests/test_format.py::test_simple_format[comments5]", "tests/test_format.py::test_simple_format[comments6]", "tests/test_format.py::test_simple_format[comments_non_breaking_space]", "tests/test_format.py::test_simple_format[comment_after_escaped_newline]", "tests/test_format.py::test_simple_format[composition]", "tests/test_format.py::test_simple_format[composition_no_trailing_comma]", "tests/test_format.py::test_simple_format[docstring]", "tests/test_format.py::test_simple_format[empty_lines]", "tests/test_format.py::test_simple_format[expression]", "tests/test_format.py::test_simple_format[fmtonoff]", "tests/test_format.py::test_simple_format[fmtonoff2]", "tests/test_format.py::test_simple_format[fmtonoff3]", "tests/test_format.py::test_simple_format[fmtonoff4]", "tests/test_format.py::test_simple_format[fmtskip]", "tests/test_format.py::test_simple_format[fmtskip2]", "tests/test_format.py::test_simple_format[fmtskip3]", "tests/test_format.py::test_simple_format[fmtskip4]", "tests/test_format.py::test_simple_format[fmtskip5]", "tests/test_format.py::test_simple_format[fmtskip6]", "tests/test_format.py::test_simple_format[fstring]", "tests/test_format.py::test_simple_format[function]", "tests/test_format.py::test_simple_format[function2]", "tests/test_format.py::test_simple_format[function_trailing_comma]", "tests/test_format.py::test_simple_format[import_spacing]", "tests/test_format.py::test_simple_format[power_op_spacing]", "tests/test_format.py::test_simple_format[remove_parens]", "tests/test_format.py::test_simple_format[slices]", "tests/test_format.py::test_simple_format[string_prefixes]", "tests/test_format.py::test_simple_format[torture]", "tests/test_format.py::test_simple_format[trailing_comma_optional_parens1]", "tests/test_format.py::test_simple_format[trailing_comma_optional_parens2]", "tests/test_format.py::test_simple_format[trailing_comma_optional_parens3]", "tests/test_format.py::test_simple_format[tricky_unicode_symbols]", "tests/test_format.py::test_simple_format[tupleassign]", "tests/test_format.py::test_preview_format[cantfit]", "tests/test_format.py::test_preview_format[comments7]", "tests/test_format.py::test_preview_format[long_strings]", "tests/test_format.py::test_preview_format[long_strings__edge_case]", "tests/test_format.py::test_preview_format[long_strings__regression]", "tests/test_format.py::test_preview_format[percent_precedence]", "tests/test_format.py::test_source_is_formatted[src/black/__init__.py]", "tests/test_format.py::test_source_is_formatted[src/black/__main__.py]", "tests/test_format.py::test_source_is_formatted[src/black/brackets.py]", "tests/test_format.py::test_source_is_formatted[src/black/cache.py]", "tests/test_format.py::test_source_is_formatted[src/black/comments.py]", "tests/test_format.py::test_source_is_formatted[src/black/concurrency.py]", "tests/test_format.py::test_source_is_formatted[src/black/const.py]", "tests/test_format.py::test_source_is_formatted[src/black/debug.py]", "tests/test_format.py::test_source_is_formatted[src/black/files.py]", "tests/test_format.py::test_source_is_formatted[src/black/linegen.py]", "tests/test_format.py::test_source_is_formatted[src/black/lines.py]", "tests/test_format.py::test_source_is_formatted[src/black/mode.py]", "tests/test_format.py::test_source_is_formatted[src/black/nodes.py]", "tests/test_format.py::test_source_is_formatted[src/black/numerics.py]", "tests/test_format.py::test_source_is_formatted[src/black/output.py]", "tests/test_format.py::test_source_is_formatted[src/black/parsing.py]", "tests/test_format.py::test_source_is_formatted[src/black/report.py]", "tests/test_format.py::test_source_is_formatted[src/black/rusty.py]", "tests/test_format.py::test_source_is_formatted[src/black/strings.py]", "tests/test_format.py::test_source_is_formatted[src/black/trans.py]", "tests/test_format.py::test_source_is_formatted[src/blackd/__init__.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pygram.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pytree.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/conv.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/driver.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/grammar.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/literals.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/parse.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/pgen.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/tokenize.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/token.py]", "tests/test_format.py::test_source_is_formatted[setup.py]", "tests/test_format.py::test_source_is_formatted[tests/test_black.py]", "tests/test_format.py::test_source_is_formatted[tests/test_blackd.py]", "tests/test_format.py::test_source_is_formatted[tests/test_format.py]", "tests/test_format.py::test_source_is_formatted[tests/optional.py]", "tests/test_format.py::test_source_is_formatted[tests/util.py]", "tests/test_format.py::test_source_is_formatted[tests/conftest.py]", "tests/test_format.py::test_empty", "tests/test_format.py::test_pep_572", "tests/test_format.py::test_pep_572_remove_parens", "tests/test_format.py::test_pep_572_do_not_remove_parens", "tests/test_format.py::test_pep_572_newer_syntax[3-9]", "tests/test_format.py::test_pep_572_newer_syntax[3-10]", "tests/test_format.py::test_pep_570", "tests/test_format.py::test_python_310[starred_for_target]", "tests/test_format.py::test_python_310[pattern_matching_simple]", "tests/test_format.py::test_python_310[pattern_matching_complex]", "tests/test_format.py::test_python_310[pattern_matching_extras]", "tests/test_format.py::test_python_310[pattern_matching_style]", "tests/test_format.py::test_python_310[pattern_matching_generic]", "tests/test_format.py::test_python_310[parenthesized_context_managers]", "tests/test_format.py::test_python_310_without_target_version", "tests/test_format.py::test_patma_invalid", "tests/test_format.py::test_python_2_hint", "tests/test_format.py::test_docstring_no_string_normalization", "tests/test_format.py::test_long_strings_flag_disabled", "tests/test_format.py::test_numeric_literals", "tests/test_format.py::test_numeric_literals_ignoring_underscores", "tests/test_format.py::test_stub", "tests/test_format.py::test_python38", "tests/test_format.py::test_python39", "tests/test_format.py::test_power_op_newline" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_media", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2022-03-18 15:33:37+00:00
mit
4,699
psf__black-2942
diff --git a/CHANGES.md b/CHANGES.md index d0faf7c..d753a24 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ <!-- Changes that affect Black's preview style --> - Code cell separators `#%%` are now standardised to `# %%` (#2919) +- Avoid magic-trailing-comma in single-element subscripts (#2942) ### _Blackd_ diff --git a/docs/guides/introducing_black_to_your_project.md b/docs/guides/introducing_black_to_your_project.md index 71ccf7c..9ae40a1 100644 --- a/docs/guides/introducing_black_to_your_project.md +++ b/docs/guides/introducing_black_to_your_project.md @@ -43,8 +43,10 @@ call to `git blame`. $ git config blame.ignoreRevsFile .git-blame-ignore-revs ``` -**The one caveat is that GitHub and GitLab do not yet support ignoring revisions using -their native UI of blame.** So blame information will be cluttered with a reformatting -commit on those platforms. (If you'd like this feature, there's an open issue for -[GitLab](https://gitlab.com/gitlab-org/gitlab/-/issues/31423) and please let GitHub -know!) +**The one caveat is that some online Git-repositories like GitLab do not yet support +ignoring revisions using their native blame UI.** So blame information will be cluttered +with a reformatting commit on those platforms. (If you'd like this feature, there's an +open issue for [GitLab](https://gitlab.com/gitlab-org/gitlab/-/issues/31423)). This is +however supported by +[GitHub](https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view), +currently in beta. diff --git a/src/black/linegen.py b/src/black/linegen.py index 79475a8..5d92011 100644 --- a/src/black/linegen.py +++ b/src/black/linegen.py @@ -8,7 +8,12 @@ from typing import Collection, Iterator, List, Optional, Set, Union from black.nodes import WHITESPACE, RARROW, STATEMENT, STANDALONE_COMMENT from black.nodes import ASSIGNMENTS, OPENING_BRACKETS, CLOSING_BRACKETS from black.nodes import Visitor, syms, is_arith_like, ensure_visible -from black.nodes import is_docstring, is_empty_tuple, is_one_tuple, is_one_tuple_between +from black.nodes import ( + is_docstring, + is_empty_tuple, + is_one_tuple, + is_one_sequence_between, +) from black.nodes import is_name_token, is_lpar_token, is_rpar_token from black.nodes import is_walrus_assignment, is_yield, is_vararg, is_multiline_string from black.nodes import is_stub_suite, is_stub_body, is_atom_with_invisible_parens @@ -973,7 +978,7 @@ def generate_trailers_to_omit(line: Line, line_length: int) -> Iterator[Set[Leaf prev and prev.type == token.COMMA and leaf.opening_bracket is not None - and not is_one_tuple_between( + and not is_one_sequence_between( leaf.opening_bracket, leaf, line.leaves ) ): @@ -1001,7 +1006,7 @@ def generate_trailers_to_omit(line: Line, line_length: int) -> Iterator[Set[Leaf prev and prev.type == token.COMMA and leaf.opening_bracket is not None - and not is_one_tuple_between(leaf.opening_bracket, leaf, line.leaves) + and not is_one_sequence_between(leaf.opening_bracket, leaf, line.leaves) ): # Never omit bracket pairs with trailing commas. # We need to explode on those. diff --git a/src/black/lines.py b/src/black/lines.py index f35665c..e455a50 100644 --- a/src/black/lines.py +++ b/src/black/lines.py @@ -17,12 +17,12 @@ from blib2to3.pytree import Node, Leaf from blib2to3.pgen2 import token from black.brackets import BracketTracker, DOT_PRIORITY -from black.mode import Mode +from black.mode import Mode, Preview from black.nodes import STANDALONE_COMMENT, TEST_DESCENDANTS from black.nodes import BRACKETS, OPENING_BRACKETS, CLOSING_BRACKETS from black.nodes import syms, whitespace, replace_child, child_towards from black.nodes import is_multiline_string, is_import, is_type_comment -from black.nodes import is_one_tuple_between +from black.nodes import is_one_sequence_between # types T = TypeVar("T") @@ -254,6 +254,7 @@ class Line: """Return True if we have a magic trailing comma, that is when: - there's a trailing comma here - it's not a one-tuple + - it's not a single-element subscript Additionally, if ensure_removable: - it's not from square bracket indexing """ @@ -268,6 +269,20 @@ class Line: return True if closing.type == token.RSQB: + if ( + Preview.one_element_subscript in self.mode + and closing.parent + and closing.parent.type == syms.trailer + and closing.opening_bracket + and is_one_sequence_between( + closing.opening_bracket, + closing, + self.leaves, + brackets=(token.LSQB, token.RSQB), + ) + ): + return False + if not ensure_removable: return True comma = self.leaves[-1] @@ -276,7 +291,7 @@ class Line: if self.is_import: return True - if closing.opening_bracket is not None and not is_one_tuple_between( + if closing.opening_bracket is not None and not is_one_sequence_between( closing.opening_bracket, closing, self.leaves ): return True diff --git a/src/black/mode.py b/src/black/mode.py index 35a072c..77b1cab 100644 --- a/src/black/mode.py +++ b/src/black/mode.py @@ -127,6 +127,7 @@ class Preview(Enum): """Individual preview style features.""" string_processing = auto() + one_element_subscript = auto() class Deprecated(UserWarning): @@ -162,9 +163,7 @@ class Mode: """ if feature is Preview.string_processing: return self.preview or self.experimental_string_processing - # TODO: Remove type ignore comment once preview contains more features - # than just ESP - return self.preview # type: ignore + return self.preview def get_cache_key(self) -> str: if self.target_versions: diff --git a/src/black/nodes.py b/src/black/nodes.py index f130bff..d18d4bd 100644 --- a/src/black/nodes.py +++ b/src/black/nodes.py @@ -9,6 +9,7 @@ from typing import ( List, Optional, Set, + Tuple, TypeVar, Union, ) @@ -559,9 +560,14 @@ def is_one_tuple(node: LN) -> bool: ) -def is_one_tuple_between(opening: Leaf, closing: Leaf, leaves: List[Leaf]) -> bool: - """Return True if content between `opening` and `closing` looks like a one-tuple.""" - if opening.type != token.LPAR and closing.type != token.RPAR: +def is_one_sequence_between( + opening: Leaf, + closing: Leaf, + leaves: List[Leaf], + brackets: Tuple[int, int] = (token.LPAR, token.RPAR), +) -> bool: + """Return True if content between `opening` and `closing` is a one-sequence.""" + if (opening.type, closing.type) != brackets: return False depth = closing.bracket_depth + 1
psf/black
5379d4f3f460ec9b7063dd1cc10f437b0edf9ae3
diff --git a/tests/data/one_element_subscript.py b/tests/data/one_element_subscript.py new file mode 100644 index 0000000..39205ba --- /dev/null +++ b/tests/data/one_element_subscript.py @@ -0,0 +1,36 @@ +# We should not treat the trailing comma +# in a single-element subscript. +a: tuple[int,] +b = tuple[int,] + +# The magic comma still applies to multi-element subscripts. +c: tuple[int, int,] +d = tuple[int, int,] + +# Magic commas still work as expected for non-subscripts. +small_list = [1,] +list_of_types = [tuple[int,],] + +# output +# We should not treat the trailing comma +# in a single-element subscript. +a: tuple[int,] +b = tuple[int,] + +# The magic comma still applies to multi-element subscripts. +c: tuple[ + int, + int, +] +d = tuple[ + int, + int, +] + +# Magic commas still work as expected for non-subscripts. +small_list = [ + 1, +] +list_of_types = [ + tuple[int,], +] diff --git a/tests/test_format.py b/tests/test_format.py index 667d5c1..4de3170 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -80,6 +80,7 @@ PREVIEW_CASES: List[str] = [ "long_strings__edge_case", "long_strings__regression", "percent_precedence", + "one_element_subscript", ] SOURCES: List[str] = [
Avoid magic-trailing-comma newline in `tuple[int,]`, like tuple literal `(1,)` Black exempts single-element tuple literals from the usual handling of magic trailing commas: `(1,)` will *not* have a newline added (as would happen for lists, sets, etc.). I'd like to be able to write type annotations for a tuple-of-one-element in the same way, so that I can write either `tuple[int,]` or `tuple[int, ...]` without looking quite so much like `list[int]`. However, Black's current add-a-newline code style makes this pattern unattractive, so I'm unlikely to write a linter for this pattern unless the code style changes. **Examples in the current _Black_ style** ```python shape: tuple[ int, ] shape = (1,) ``` **Desired style** ```python shape: tuple[int,] shape = (1,) ```
0.0
5379d4f3f460ec9b7063dd1cc10f437b0edf9ae3
[ "tests/test_format.py::test_preview_format[one_element_subscript]" ]
[ "tests/test_format.py::test_simple_format[attribute_access_on_number_literals]", "tests/test_format.py::test_simple_format[beginning_backslash]", "tests/test_format.py::test_simple_format[bracketmatch]", "tests/test_format.py::test_simple_format[class_blank_parentheses]", "tests/test_format.py::test_simple_format[class_methods_new_line]", "tests/test_format.py::test_simple_format[collections]", "tests/test_format.py::test_simple_format[comments]", "tests/test_format.py::test_simple_format[comments2]", "tests/test_format.py::test_simple_format[comments3]", "tests/test_format.py::test_simple_format[comments4]", "tests/test_format.py::test_simple_format[comments5]", "tests/test_format.py::test_simple_format[comments6]", "tests/test_format.py::test_simple_format[comments_non_breaking_space]", "tests/test_format.py::test_simple_format[comment_after_escaped_newline]", "tests/test_format.py::test_simple_format[composition]", "tests/test_format.py::test_simple_format[composition_no_trailing_comma]", "tests/test_format.py::test_simple_format[docstring]", "tests/test_format.py::test_simple_format[empty_lines]", "tests/test_format.py::test_simple_format[expression]", "tests/test_format.py::test_simple_format[fmtonoff]", "tests/test_format.py::test_simple_format[fmtonoff2]", "tests/test_format.py::test_simple_format[fmtonoff3]", "tests/test_format.py::test_simple_format[fmtonoff4]", "tests/test_format.py::test_simple_format[fmtskip]", "tests/test_format.py::test_simple_format[fmtskip2]", "tests/test_format.py::test_simple_format[fmtskip3]", "tests/test_format.py::test_simple_format[fmtskip4]", "tests/test_format.py::test_simple_format[fmtskip5]", "tests/test_format.py::test_simple_format[fmtskip6]", "tests/test_format.py::test_simple_format[fstring]", "tests/test_format.py::test_simple_format[function]", "tests/test_format.py::test_simple_format[function2]", "tests/test_format.py::test_simple_format[function_trailing_comma]", "tests/test_format.py::test_simple_format[import_spacing]", "tests/test_format.py::test_simple_format[power_op_spacing]", "tests/test_format.py::test_simple_format[remove_parens]", "tests/test_format.py::test_simple_format[slices]", "tests/test_format.py::test_simple_format[string_prefixes]", "tests/test_format.py::test_simple_format[torture]", "tests/test_format.py::test_simple_format[trailing_comma_optional_parens1]", "tests/test_format.py::test_simple_format[trailing_comma_optional_parens2]", "tests/test_format.py::test_simple_format[trailing_comma_optional_parens3]", "tests/test_format.py::test_simple_format[tricky_unicode_symbols]", "tests/test_format.py::test_simple_format[tupleassign]", "tests/test_format.py::test_preview_format[cantfit]", "tests/test_format.py::test_preview_format[comments7]", "tests/test_format.py::test_preview_format[comments8]", "tests/test_format.py::test_preview_format[long_strings]", "tests/test_format.py::test_preview_format[long_strings__edge_case]", "tests/test_format.py::test_preview_format[long_strings__regression]", "tests/test_format.py::test_preview_format[percent_precedence]", "tests/test_format.py::test_source_is_formatted[src/black/__init__.py]", "tests/test_format.py::test_source_is_formatted[src/black/__main__.py]", "tests/test_format.py::test_source_is_formatted[src/black/brackets.py]", "tests/test_format.py::test_source_is_formatted[src/black/cache.py]", "tests/test_format.py::test_source_is_formatted[src/black/comments.py]", "tests/test_format.py::test_source_is_formatted[src/black/concurrency.py]", "tests/test_format.py::test_source_is_formatted[src/black/const.py]", "tests/test_format.py::test_source_is_formatted[src/black/debug.py]", "tests/test_format.py::test_source_is_formatted[src/black/files.py]", "tests/test_format.py::test_source_is_formatted[src/black/linegen.py]", "tests/test_format.py::test_source_is_formatted[src/black/lines.py]", "tests/test_format.py::test_source_is_formatted[src/black/mode.py]", "tests/test_format.py::test_source_is_formatted[src/black/nodes.py]", "tests/test_format.py::test_source_is_formatted[src/black/numerics.py]", "tests/test_format.py::test_source_is_formatted[src/black/output.py]", "tests/test_format.py::test_source_is_formatted[src/black/parsing.py]", "tests/test_format.py::test_source_is_formatted[src/black/report.py]", "tests/test_format.py::test_source_is_formatted[src/black/rusty.py]", "tests/test_format.py::test_source_is_formatted[src/black/strings.py]", "tests/test_format.py::test_source_is_formatted[src/black/trans.py]", "tests/test_format.py::test_source_is_formatted[src/blackd/__init__.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pygram.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pytree.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/conv.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/driver.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/grammar.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/literals.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/parse.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/pgen.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/tokenize.py]", "tests/test_format.py::test_source_is_formatted[src/blib2to3/pgen2/token.py]", "tests/test_format.py::test_source_is_formatted[setup.py]", "tests/test_format.py::test_source_is_formatted[tests/test_black.py]", "tests/test_format.py::test_source_is_formatted[tests/test_blackd.py]", "tests/test_format.py::test_source_is_formatted[tests/test_format.py]", "tests/test_format.py::test_source_is_formatted[tests/optional.py]", "tests/test_format.py::test_source_is_formatted[tests/util.py]", "tests/test_format.py::test_source_is_formatted[tests/conftest.py]", "tests/test_format.py::test_empty", "tests/test_format.py::test_pep_572", "tests/test_format.py::test_pep_572_remove_parens", "tests/test_format.py::test_pep_572_do_not_remove_parens", "tests/test_format.py::test_pep_572_newer_syntax[3-9]", "tests/test_format.py::test_pep_572_newer_syntax[3-10]", "tests/test_format.py::test_pep_570", "tests/test_format.py::test_python_310[starred_for_target]", "tests/test_format.py::test_python_310[pattern_matching_simple]", "tests/test_format.py::test_python_310[pattern_matching_complex]", "tests/test_format.py::test_python_310[pattern_matching_extras]", "tests/test_format.py::test_python_310[pattern_matching_style]", "tests/test_format.py::test_python_310[pattern_matching_generic]", "tests/test_format.py::test_python_310[parenthesized_context_managers]", "tests/test_format.py::test_python_310_without_target_version", "tests/test_format.py::test_patma_invalid", "tests/test_format.py::test_python_2_hint", "tests/test_format.py::test_docstring_no_string_normalization", "tests/test_format.py::test_long_strings_flag_disabled", "tests/test_format.py::test_numeric_literals", "tests/test_format.py::test_numeric_literals_ignoring_underscores", "tests/test_format.py::test_stub", "tests/test_format.py::test_python38", "tests/test_format.py::test_python39", "tests/test_format.py::test_power_op_newline" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2022-03-18 17:10:00+00:00
mit
4,700
psf__black-3215
diff --git a/CHANGES.md b/CHANGES.md index 5b29f20..1fc8c65 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -33,6 +33,8 @@ <!-- Changes to how Black can be configured --> +- Black now uses the presence of debug f-strings to detect target version. (#3215) + ### Documentation <!-- Major changes to documentation and policies. Small docs changes diff --git a/src/black/__init__.py b/src/black/__init__.py index 2a5c750..b8a9d03 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -87,6 +87,7 @@ from black.output import color_diff, diff, dump_to_file, err, ipynb_diff, out from black.parsing import InvalidInput # noqa F401 from black.parsing import lib2to3_parse, parse_ast, stringify_ast from black.report import Changed, NothingChanged, Report +from black.trans import iter_fexpr_spans from blib2to3.pgen2 import token from blib2to3.pytree import Leaf, Node @@ -1240,6 +1241,7 @@ def get_features_used( # noqa: C901 Currently looking for: - f-strings; + - self-documenting expressions in f-strings (f"{x=}"); - underscores in numeric literals; - trailing commas after * or ** in function signatures and calls; - positional only arguments in function signatures and lambdas; @@ -1261,6 +1263,11 @@ def get_features_used( # noqa: C901 value_head = n.value[:2] if value_head in {'f"', 'F"', "f'", "F'", "rf", "fr", "RF", "FR"}: features.add(Feature.F_STRINGS) + if Feature.DEBUG_F_STRINGS not in features: + for span_beg, span_end in iter_fexpr_spans(n.value): + if n.value[span_beg : span_end - 1].rstrip().endswith("="): + features.add(Feature.DEBUG_F_STRINGS) + break elif is_number_token(n): if "_" in n.value: diff --git a/src/black/mode.py b/src/black/mode.py index 32b65d1..f6d0cbf 100644 --- a/src/black/mode.py +++ b/src/black/mode.py @@ -49,6 +49,7 @@ class Feature(Enum): ANN_ASSIGN_EXTENDED_RHS = 13 EXCEPT_STAR = 14 VARIADIC_GENERICS = 15 + DEBUG_F_STRINGS = 16 FORCE_OPTIONAL_PARENTHESES = 50 # __future__ flags @@ -81,6 +82,7 @@ VERSION_TO_FEATURES: Dict[TargetVersion, Set[Feature]] = { }, TargetVersion.PY38: { Feature.F_STRINGS, + Feature.DEBUG_F_STRINGS, Feature.NUMERIC_UNDERSCORES, Feature.TRAILING_COMMA_IN_CALL, Feature.TRAILING_COMMA_IN_DEF, @@ -93,6 +95,7 @@ VERSION_TO_FEATURES: Dict[TargetVersion, Set[Feature]] = { }, TargetVersion.PY39: { Feature.F_STRINGS, + Feature.DEBUG_F_STRINGS, Feature.NUMERIC_UNDERSCORES, Feature.TRAILING_COMMA_IN_CALL, Feature.TRAILING_COMMA_IN_DEF, @@ -106,6 +109,7 @@ VERSION_TO_FEATURES: Dict[TargetVersion, Set[Feature]] = { }, TargetVersion.PY310: { Feature.F_STRINGS, + Feature.DEBUG_F_STRINGS, Feature.NUMERIC_UNDERSCORES, Feature.TRAILING_COMMA_IN_CALL, Feature.TRAILING_COMMA_IN_DEF, @@ -120,6 +124,7 @@ VERSION_TO_FEATURES: Dict[TargetVersion, Set[Feature]] = { }, TargetVersion.PY311: { Feature.F_STRINGS, + Feature.DEBUG_F_STRINGS, Feature.NUMERIC_UNDERSCORES, Feature.TRAILING_COMMA_IN_CALL, Feature.TRAILING_COMMA_IN_DEF,
psf/black
507234c47d39f5b1d8289cdd49994e03dd97bcb4
diff --git a/tests/test_black.py b/tests/test_black.py index bb7784d..81e7a9a 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -310,6 +310,26 @@ class BlackTestCase(BlackBaseTestCase): versions = black.detect_target_versions(root) self.assertIn(black.TargetVersion.PY38, versions) + def test_detect_debug_f_strings(self) -> None: + root = black.lib2to3_parse("""f"{x=}" """) + features = black.get_features_used(root) + self.assertIn(black.Feature.DEBUG_F_STRINGS, features) + versions = black.detect_target_versions(root) + self.assertIn(black.TargetVersion.PY38, versions) + + root = black.lib2to3_parse( + """f"{x}"\nf'{"="}'\nf'{(x:=5)}'\nf'{f(a="3=")}'\nf'{x:=10}'\n""" + ) + features = black.get_features_used(root) + self.assertNotIn(black.Feature.DEBUG_F_STRINGS, features) + + # We don't yet support feature version detection in nested f-strings + root = black.lib2to3_parse( + """f"heard a rumour that { f'{1+1=}' } ... seems like it could be true" """ + ) + features = black.get_features_used(root) + self.assertNotIn(black.Feature.DEBUG_F_STRINGS, features) + @patch("black.dump_to_file", dump_to_stderr) def test_string_quotes(self) -> None: source, expected = read_data("miscellaneous", "string_quotes")
When detecting Python versions, `f"{x=}"` should imply 3.8+ **Describe the bug** The `=` specifier was added to f-strings in Python 3.8, but Black does not yet distinguish it from any other f-string, and therefore detects the version as 3.6+. This leads to missed formatting opportunities, and sometimes problems in downstream projects since this is invalid syntax under earlier versions. (e.g. https://github.com/Zac-HD/shed/issues/31, prompting this issue) **To Reproduce** ```python from black import detect_target_versions, parsing code = parsing.lib2to3_parse(""" f'{x=}' """) print(detect_target_versions(code)) ``` ``` $ python repro.py {<TargetVersion.PY36: 6>, <TargetVersion.PY37: 7>, <TargetVersion.PY38: 8>, <TargetVersion.PY39: 9>, <TargetVersion.PY310: 10>} ```
0.0
507234c47d39f5b1d8289cdd49994e03dd97bcb4
[ "tests/test_black.py::BlackTestCase::test_detect_debug_f_strings" ]
[ "tests/test_black.py::BlackTestCase::test_assertFormatEqual", "tests/test_black.py::BlackTestCase::test_assert_equivalent_different_asts", "tests/test_black.py::BlackTestCase::test_async_as_identifier", "tests/test_black.py::BlackTestCase::test_bpo_2142_workaround", "tests/test_black.py::BlackTestCase::test_bpo_33660_workaround", "tests/test_black.py::BlackTestCase::test_broken_symlink", "tests/test_black.py::BlackTestCase::test_check_diff_use_together", "tests/test_black.py::BlackTestCase::test_code_option", "tests/test_black.py::BlackTestCase::test_code_option_changed", "tests/test_black.py::BlackTestCase::test_code_option_check", "tests/test_black.py::BlackTestCase::test_code_option_check_changed", "tests/test_black.py::BlackTestCase::test_code_option_color_diff", "tests/test_black.py::BlackTestCase::test_code_option_config", "tests/test_black.py::BlackTestCase::test_code_option_diff", "tests/test_black.py::BlackTestCase::test_code_option_fast", "tests/test_black.py::BlackTestCase::test_code_option_parent_config", "tests/test_black.py::BlackTestCase::test_code_option_safe", "tests/test_black.py::BlackTestCase::test_debug_visitor", "tests/test_black.py::BlackTestCase::test_detect_pos_only_arguments", "tests/test_black.py::BlackTestCase::test_empty_ff", "tests/test_black.py::BlackTestCase::test_endmarker", "tests/test_black.py::BlackTestCase::test_equivalency_ast_parse_failure_includes_error", "tests/test_black.py::BlackTestCase::test_experimental_string_processing_warns", "tests/test_black.py::BlackTestCase::test_expression_diff", "tests/test_black.py::BlackTestCase::test_expression_diff_with_color", "tests/test_black.py::BlackTestCase::test_expression_ff", "tests/test_black.py::BlackTestCase::test_find_project_root", "tests/test_black.py::BlackTestCase::test_find_pyproject_toml", "tests/test_black.py::BlackTestCase::test_find_user_pyproject_toml_linux", "tests/test_black.py::BlackTestCase::test_find_user_pyproject_toml_windows", "tests/test_black.py::BlackTestCase::test_for_handled_unexpected_eof_error", "tests/test_black.py::BlackTestCase::test_format_file_contents", "tests/test_black.py::BlackTestCase::test_get_features_used", "tests/test_black.py::BlackTestCase::test_get_features_used_decorator", "tests/test_black.py::BlackTestCase::test_get_features_used_for_future_flags", "tests/test_black.py::BlackTestCase::test_get_future_imports", "tests/test_black.py::BlackTestCase::test_invalid_cli_regex", "tests/test_black.py::BlackTestCase::test_invalid_config_return_code", "tests/test_black.py::BlackTestCase::test_lib2to3_parse", "tests/test_black.py::BlackTestCase::test_multi_file_force_py36", "tests/test_black.py::BlackTestCase::test_multi_file_force_pyi", "tests/test_black.py::BlackTestCase::test_newline_comment_interaction", "tests/test_black.py::BlackTestCase::test_no_src_fails", "tests/test_black.py::BlackTestCase::test_normalize_path_ignore_windows_junctions_outside_of_root", "tests/test_black.py::BlackTestCase::test_parse_pyproject_toml", "tests/test_black.py::BlackTestCase::test_pep_572_version_detection", "tests/test_black.py::BlackTestCase::test_pipe_force_py36", "tests/test_black.py::BlackTestCase::test_pipe_force_pyi", "tests/test_black.py::BlackTestCase::test_piping", "tests/test_black.py::BlackTestCase::test_piping_diff", "tests/test_black.py::BlackTestCase::test_piping_diff_with_color", "tests/test_black.py::BlackTestCase::test_preserves_line_endings", "tests/test_black.py::BlackTestCase::test_preserves_line_endings_via_stdin", "tests/test_black.py::BlackTestCase::test_python37", "tests/test_black.py::BlackTestCase::test_read_pyproject_toml", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_and_existing_path", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_empty", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename_ipynb", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename_pyi", "tests/test_black.py::BlackTestCase::test_report_normal", "tests/test_black.py::BlackTestCase::test_report_quiet", "tests/test_black.py::BlackTestCase::test_report_verbose", "tests/test_black.py::BlackTestCase::test_required_version_does_not_match_on_minor_version", "tests/test_black.py::BlackTestCase::test_required_version_does_not_match_version", "tests/test_black.py::BlackTestCase::test_required_version_matches_partial_version", "tests/test_black.py::BlackTestCase::test_required_version_matches_version", "tests/test_black.py::BlackTestCase::test_root_logger_not_used_directly", "tests/test_black.py::BlackTestCase::test_single_file_force_py36", "tests/test_black.py::BlackTestCase::test_single_file_force_pyi", "tests/test_black.py::BlackTestCase::test_skip_magic_trailing_comma", "tests/test_black.py::BlackTestCase::test_src_and_code_fails", "tests/test_black.py::BlackTestCase::test_string_quotes", "tests/test_black.py::BlackTestCase::test_tab_comment_indentation", "tests/test_black.py::BlackTestCase::test_works_in_mono_process_only_environment", "tests/test_black.py::TestCaching::test_get_cache_dir", "tests/test_black.py::TestCaching::test_cache_broken_file", "tests/test_black.py::TestCaching::test_cache_single_file_already_cached", "tests/test_black.py::TestCaching::test_cache_multiple_files", "tests/test_black.py::TestCaching::test_no_cache_when_writeback_diff[no-color]", "tests/test_black.py::TestCaching::test_no_cache_when_writeback_diff[with-color]", "tests/test_black.py::TestCaching::test_output_locking_when_writeback_diff[no-color]", "tests/test_black.py::TestCaching::test_output_locking_when_writeback_diff[with-color]", "tests/test_black.py::TestCaching::test_no_cache_when_stdin", "tests/test_black.py::TestCaching::test_read_cache_no_cachefile", "tests/test_black.py::TestCaching::test_write_cache_read_cache", "tests/test_black.py::TestCaching::test_filter_cached", "tests/test_black.py::TestCaching::test_write_cache_creates_directory_if_needed", "tests/test_black.py::TestCaching::test_failed_formatting_does_not_get_cached", "tests/test_black.py::TestCaching::test_write_cache_write_fail", "tests/test_black.py::TestCaching::test_read_cache_line_lengths", "tests/test_black.py::TestFileCollection::test_include_exclude", "tests/test_black.py::TestFileCollection::test_gitignore_used_as_default", "tests/test_black.py::TestFileCollection::test_exclude_for_issue_1572", "tests/test_black.py::TestFileCollection::test_gitignore_exclude", "tests/test_black.py::TestFileCollection::test_nested_gitignore", "tests/test_black.py::TestFileCollection::test_invalid_gitignore", "tests/test_black.py::TestFileCollection::test_invalid_nested_gitignore", "tests/test_black.py::TestFileCollection::test_empty_include", "tests/test_black.py::TestFileCollection::test_extend_exclude", "tests/test_black.py::TestFileCollection::test_symlink_out_of_root_directory", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_extend_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_force_exclude" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2022-08-10 03:46:56+00:00
mit
4,701
psf__black-4161
diff --git a/.github/workflows/diff_shades.yml b/.github/workflows/diff_shades.yml index 8d8be25..0e1aab0 100644 --- a/.github/workflows/diff_shades.yml +++ b/.github/workflows/diff_shades.yml @@ -72,7 +72,7 @@ jobs: - name: Attempt to use cached baseline analysis id: baseline-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ matrix.baseline-analysis }} key: ${{ matrix.baseline-cache-key }} diff --git a/CHANGES.md b/CHANGES.md index 1e75fb5..f29834a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -29,6 +29,8 @@ <!-- Changes to how Black can be configured --> +- Fix symlink handling, properly catch and ignore symlinks that point outside of root + (#4161) - Fix cache mtime logic that resulted in false positive cache hits (#4128) ### Packaging diff --git a/src/black/__init__.py b/src/black/__init__.py index 735ba71..e3cbaab 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -49,6 +49,7 @@ from black.files import ( find_user_pyproject_toml, gen_python_files, get_gitignore, + get_root_relative_path, normalize_path_maybe_ignore, parse_pyproject_toml, path_is_excluded, @@ -700,7 +701,10 @@ def get_sources( # Compare the logic here to the logic in `gen_python_files`. if is_stdin or path.is_file(): - root_relative_path = path.absolute().relative_to(root).as_posix() + root_relative_path = get_root_relative_path(path, root, report) + + if root_relative_path is None: + continue root_relative_path = "/" + root_relative_path diff --git a/src/black/files.py b/src/black/files.py index 858303c..65951ef 100644 --- a/src/black/files.py +++ b/src/black/files.py @@ -259,14 +259,7 @@ def normalize_path_maybe_ignore( try: abspath = path if path.is_absolute() else Path.cwd() / path normalized_path = abspath.resolve() - try: - root_relative_path = normalized_path.relative_to(root).as_posix() - except ValueError: - if report: - report.path_ignored( - path, f"is a symbolic link that points outside {root}" - ) - return None + root_relative_path = get_root_relative_path(normalized_path, root, report) except OSError as e: if report: @@ -276,6 +269,21 @@ def normalize_path_maybe_ignore( return root_relative_path +def get_root_relative_path( + path: Path, + root: Path, + report: Optional[Report] = None, +) -> Optional[str]: + """Returns the file path relative to the 'root' directory""" + try: + root_relative_path = path.absolute().relative_to(root).as_posix() + except ValueError: + if report: + report.path_ignored(path, f"is a symbolic link that points outside {root}") + return None + return root_relative_path + + def _path_is_ignored( root_relative_path: str, root: Path,
psf/black
995e4ada14d63a9bec39c5fc83275d0e49742618
diff --git a/tests/test_black.py b/tests/test_black.py index 0af5fd2..2b5fab5 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -2592,6 +2592,20 @@ class TestFileCollection: outside_root_symlink.resolve.assert_called_once() ignored_symlink.resolve.assert_not_called() + def test_get_sources_with_stdin_symlink_outside_root( + self, + ) -> None: + path = THIS_DIR / "data" / "include_exclude_tests" + stdin_filename = str(path / "b/exclude/a.py") + outside_root_symlink = Path("/target_directory/a.py") + with patch("pathlib.Path.resolve", return_value=outside_root_symlink): + assert_collected_sources( + root=Path("target_directory/"), + src=["-"], + expected=[], + stdin_filename=stdin_filename, + ) + @patch("black.find_project_root", lambda *args: (THIS_DIR.resolve(), None)) def test_get_sources_with_stdin(self) -> None: src = ["-"]
pathlib exception when symlinks are involved **Describe the bug** Hello! First of all, thank you for this invaluable tool. I first ran into this issue on Windows when using black to format code located on a mapped network drive. This line in [get_sources()](https://github.com/psf/black/blob/a0e270d0f246387202e676b25abbf7a02ddcbc71/src/black/__init__.py#L656C17-L656C17) doesn't ignore symlinks pointing outside of `root`, which has symlinks resolved by [find_project_root()](https://github.com/psf/black/blob/a0e270d0f246387202e676b25abbf7a02ddcbc71/src/black/files.py#L46): https://github.com/psf/black/blob/a0e270d0f246387202e676b25abbf7a02ddcbc71/src/black/__init__.py#L687 **To Reproduce on Linux** ```shell mkdir test_black ln -s test_black test_black_sym cd test_black git init echo "print('hello')" > app.py black ~/test_black_sym/app.py ``` `git init` is needed so that [find_project_root()](https://github.com/psf/black/blob/main/src/black/files.py#L46) doesn't return the root of the file system. The resulting error is: ```shell Traceback (most recent call last): <some omitted> File "/home/tg2648/black/src/black/__init__.py", line 600, in main sources = get_sources( ^^^^^^^^^^^^ File "/home/tg2648/black/src/black/__init__.py", line 687, in get_sources root_relative_path = path.absolute().relative_to(root).as_posix() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tg2648/.pyenv/versions/3.11.0/lib/python3.11/pathlib.py", line 730, in relative_to raise ValueError("{!r} is not in the subpath of {!r}" ValueError: '/home/tg2648/test_black_sym/app.py' is not in the subpath of '/home/tg2648/test_black' OR one path is relative and the other is absolute. ``` **Environment** <!-- Please complete the following information: --> - Black's version: 23.11.0 - OS and Python version: Windows and Linux / Python 3.11.0 **Ideas** [normalize_path_maybe_ignore()](https://github.com/psf/black/blob/main/src/black/files.py#L250), which is used later in `get_sources()`, also calculates the root relative path but catches the `ValueError` exception: https://github.com/psf/black/blob/46be1f8e54ac9a7d67723c0fa28c7bec13a0a2bf/src/black/files.py#L262-L269 Maybe one solution is to extract these lines into a function like `get_root_relative_path` and then use it in `get_sources()` and `normalize_path_maybe_ignore()`. I can submit a PR if this sounds reasonable.
0.0
995e4ada14d63a9bec39c5fc83275d0e49742618
[ "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_symlink_outside_root" ]
[ "tests/test_black.py::BlackTestCase::test_assertFormatEqual_print_full_tree", "tests/test_black.py::BlackTestCase::test_assertFormatEqual_print_tree_diff", "tests/test_black.py::BlackTestCase::test_assert_equivalent_different_asts", "tests/test_black.py::BlackTestCase::test_async_as_identifier", "tests/test_black.py::BlackTestCase::test_bpo_2142_workaround", "tests/test_black.py::BlackTestCase::test_bpo_33660_workaround", "tests/test_black.py::BlackTestCase::test_broken_symlink", "tests/test_black.py::BlackTestCase::test_check_diff_use_together", "tests/test_black.py::BlackTestCase::test_code_option", "tests/test_black.py::BlackTestCase::test_code_option_changed", "tests/test_black.py::BlackTestCase::test_code_option_check", "tests/test_black.py::BlackTestCase::test_code_option_check_changed", "tests/test_black.py::BlackTestCase::test_code_option_color_diff", "tests/test_black.py::BlackTestCase::test_code_option_config", "tests/test_black.py::BlackTestCase::test_code_option_diff", "tests/test_black.py::BlackTestCase::test_code_option_fast", "tests/test_black.py::BlackTestCase::test_code_option_parent_config", "tests/test_black.py::BlackTestCase::test_code_option_safe", "tests/test_black.py::BlackTestCase::test_debug_visitor", "tests/test_black.py::BlackTestCase::test_detect_debug_f_strings", "tests/test_black.py::BlackTestCase::test_detect_pos_only_arguments", "tests/test_black.py::BlackTestCase::test_empty_ff", "tests/test_black.py::BlackTestCase::test_endmarker", "tests/test_black.py::BlackTestCase::test_equivalency_ast_parse_failure_includes_error", "tests/test_black.py::BlackTestCase::test_experimental_string_processing_warns", "tests/test_black.py::BlackTestCase::test_expression_diff", "tests/test_black.py::BlackTestCase::test_expression_diff_with_color", "tests/test_black.py::BlackTestCase::test_expression_ff", "tests/test_black.py::BlackTestCase::test_false_positive_symlink_output_issue_3384", "tests/test_black.py::BlackTestCase::test_find_project_root", "tests/test_black.py::BlackTestCase::test_find_pyproject_toml", "tests/test_black.py::BlackTestCase::test_find_user_pyproject_toml_linux", "tests/test_black.py::BlackTestCase::test_find_user_pyproject_toml_windows", "tests/test_black.py::BlackTestCase::test_for_handled_unexpected_eof_error", "tests/test_black.py::BlackTestCase::test_format_file_contents", "tests/test_black.py::BlackTestCase::test_get_features_used", "tests/test_black.py::BlackTestCase::test_get_features_used_decorator", "tests/test_black.py::BlackTestCase::test_get_features_used_for_future_flags", "tests/test_black.py::BlackTestCase::test_get_future_imports", "tests/test_black.py::BlackTestCase::test_infer_target_version", "tests/test_black.py::BlackTestCase::test_invalid_cli_regex", "tests/test_black.py::BlackTestCase::test_invalid_config_return_code", "tests/test_black.py::BlackTestCase::test_lib2to3_parse", "tests/test_black.py::BlackTestCase::test_line_ranges_in_pyproject_toml", "tests/test_black.py::BlackTestCase::test_line_ranges_with_code_option", "tests/test_black.py::BlackTestCase::test_line_ranges_with_ipynb", "tests/test_black.py::BlackTestCase::test_line_ranges_with_multiple_sources", "tests/test_black.py::BlackTestCase::test_line_ranges_with_source", "tests/test_black.py::BlackTestCase::test_line_ranges_with_stdin", "tests/test_black.py::BlackTestCase::test_multi_file_force_py36", "tests/test_black.py::BlackTestCase::test_multi_file_force_pyi", "tests/test_black.py::BlackTestCase::test_newline_comment_interaction", "tests/test_black.py::BlackTestCase::test_no_src_fails", "tests/test_black.py::BlackTestCase::test_normalize_line_endings", "tests/test_black.py::BlackTestCase::test_normalize_path_ignore_windows_junctions_outside_of_root", "tests/test_black.py::BlackTestCase::test_one_empty_line", "tests/test_black.py::BlackTestCase::test_one_empty_line_ff", "tests/test_black.py::BlackTestCase::test_parse_pyproject_toml", "tests/test_black.py::BlackTestCase::test_parse_pyproject_toml_project_metadata", "tests/test_black.py::BlackTestCase::test_pep_572_version_detection", "tests/test_black.py::BlackTestCase::test_pep_695_version_detection", "tests/test_black.py::BlackTestCase::test_pipe_force_py36", "tests/test_black.py::BlackTestCase::test_pipe_force_pyi", "tests/test_black.py::BlackTestCase::test_piping", "tests/test_black.py::BlackTestCase::test_piping_diff", "tests/test_black.py::BlackTestCase::test_piping_diff_with_color", "tests/test_black.py::BlackTestCase::test_preserves_line_endings", "tests/test_black.py::BlackTestCase::test_preserves_line_endings_via_stdin", "tests/test_black.py::BlackTestCase::test_python37", "tests/test_black.py::BlackTestCase::test_read_pyproject_toml", "tests/test_black.py::BlackTestCase::test_read_pyproject_toml_from_stdin", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_and_existing_path", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_empty", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename_ipynb", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename_pyi", "tests/test_black.py::BlackTestCase::test_report_normal", "tests/test_black.py::BlackTestCase::test_report_quiet", "tests/test_black.py::BlackTestCase::test_report_verbose", "tests/test_black.py::BlackTestCase::test_required_version_does_not_match_on_minor_version", "tests/test_black.py::BlackTestCase::test_required_version_does_not_match_version", "tests/test_black.py::BlackTestCase::test_required_version_matches_partial_version", "tests/test_black.py::BlackTestCase::test_required_version_matches_version", "tests/test_black.py::BlackTestCase::test_root_logger_not_used_directly", "tests/test_black.py::BlackTestCase::test_single_file_force_py36", "tests/test_black.py::BlackTestCase::test_single_file_force_pyi", "tests/test_black.py::BlackTestCase::test_skip_magic_trailing_comma", "tests/test_black.py::BlackTestCase::test_skip_source_first_line", "tests/test_black.py::BlackTestCase::test_skip_source_first_line_when_mixing_newlines", "tests/test_black.py::BlackTestCase::test_src_and_code_fails", "tests/test_black.py::BlackTestCase::test_string_quotes", "tests/test_black.py::BlackTestCase::test_tab_comment_indentation", "tests/test_black.py::BlackTestCase::test_works_in_mono_process_only_environment", "tests/test_black.py::TestCaching::test_get_cache_dir", "tests/test_black.py::TestCaching::test_cache_broken_file", "tests/test_black.py::TestCaching::test_cache_single_file_already_cached", "tests/test_black.py::TestCaching::test_cache_multiple_files", "tests/test_black.py::TestCaching::test_no_cache_when_writeback_diff[no-color]", "tests/test_black.py::TestCaching::test_no_cache_when_writeback_diff[with-color]", "tests/test_black.py::TestCaching::test_output_locking_when_writeback_diff[no-color]", "tests/test_black.py::TestCaching::test_output_locking_when_writeback_diff[with-color]", "tests/test_black.py::TestCaching::test_no_cache_when_stdin", "tests/test_black.py::TestCaching::test_read_cache_no_cachefile", "tests/test_black.py::TestCaching::test_write_cache_read_cache", "tests/test_black.py::TestCaching::test_filter_cached", "tests/test_black.py::TestCaching::test_filter_cached_hash", "tests/test_black.py::TestCaching::test_write_cache_creates_directory_if_needed", "tests/test_black.py::TestCaching::test_failed_formatting_does_not_get_cached", "tests/test_black.py::TestCaching::test_write_cache_write_fail", "tests/test_black.py::TestCaching::test_read_cache_line_lengths", "tests/test_black.py::TestFileCollection::test_include_exclude", "tests/test_black.py::TestFileCollection::test_gitignore_used_as_default", "tests/test_black.py::TestFileCollection::test_gitignore_used_on_multiple_sources", "tests/test_black.py::TestFileCollection::test_exclude_for_issue_1572", "tests/test_black.py::TestFileCollection::test_gitignore_exclude", "tests/test_black.py::TestFileCollection::test_nested_gitignore", "tests/test_black.py::TestFileCollection::test_nested_gitignore_directly_in_source_directory", "tests/test_black.py::TestFileCollection::test_invalid_gitignore", "tests/test_black.py::TestFileCollection::test_invalid_nested_gitignore", "tests/test_black.py::TestFileCollection::test_gitignore_that_ignores_subfolders", "tests/test_black.py::TestFileCollection::test_empty_include", "tests/test_black.py::TestFileCollection::test_include_absolute_path", "tests/test_black.py::TestFileCollection::test_exclude_absolute_path", "tests/test_black.py::TestFileCollection::test_extend_exclude", "tests/test_black.py::TestFileCollection::test_symlinks", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_extend_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_force_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_force_exclude_and_symlink", "tests/test_black.py::TestDeFactoAPI::test_format_str", "tests/test_black.py::TestDeFactoAPI::test_format_file_contents" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2024-01-22 06:52:26+00:00
mit
4,702
psf__black-4176
diff --git a/CHANGES.md b/CHANGES.md index 9a9be4b..e4240ea 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,9 @@ <!-- Changes to how Black can be configured --> +- Shorten the length of the name of the cache file to fix crashes on file systems that + do not support long paths (#4176) + ### Packaging <!-- Changes to how Black is packaged, such as dependency requirements --> diff --git a/src/black/cache.py b/src/black/cache.py index cfdbc21..35bddb5 100644 --- a/src/black/cache.py +++ b/src/black/cache.py @@ -13,6 +13,7 @@ from platformdirs import user_cache_dir from _black_version import version as __version__ from black.mode import Mode +from black.output import err if sys.version_info >= (3, 11): from typing import Self @@ -64,7 +65,13 @@ class Cache: resolve the issue. """ cache_file = get_cache_file(mode) - if not cache_file.exists(): + try: + exists = cache_file.exists() + except OSError as e: + # Likely file too long; see #4172 and #4174 + err(f"Unable to read cache file {cache_file} due to {e}") + return cls(mode, cache_file) + if not exists: return cls(mode, cache_file) with cache_file.open("rb") as fobj: diff --git a/src/black/mode.py b/src/black/mode.py index 68919fb..128d2b9 100644 --- a/src/black/mode.py +++ b/src/black/mode.py @@ -192,6 +192,9 @@ class Deprecated(UserWarning): """Visible deprecation warning.""" +_MAX_CACHE_KEY_PART_LENGTH: Final = 32 + + @dataclass class Mode: target_versions: Set[TargetVersion] = field(default_factory=set) @@ -228,6 +231,19 @@ class Mode: ) else: version_str = "-" + if len(version_str) > _MAX_CACHE_KEY_PART_LENGTH: + version_str = sha256(version_str.encode()).hexdigest()[ + :_MAX_CACHE_KEY_PART_LENGTH + ] + features_and_magics = ( + ",".join(sorted(f.name for f in self.enabled_features)) + + "@" + + ",".join(sorted(self.python_cell_magics)) + ) + if len(features_and_magics) > _MAX_CACHE_KEY_PART_LENGTH: + features_and_magics = sha256(features_and_magics.encode()).hexdigest()[ + :_MAX_CACHE_KEY_PART_LENGTH + ] parts = [ version_str, str(self.line_length), @@ -236,10 +252,7 @@ class Mode: str(int(self.is_ipynb)), str(int(self.skip_source_first_line)), str(int(self.magic_trailing_comma)), - sha256( - (",".join(sorted(f.name for f in self.enabled_features))).encode() - ).hexdigest(), str(int(self.preview)), - sha256((",".join(sorted(self.python_cell_magics))).encode()).hexdigest(), + features_and_magics, ] return ".".join(parts)
psf/black
659c29a41c7c686687aef21f57b95bcfa236b03b
diff --git a/tests/test_black.py b/tests/test_black.py index 6dbe25a..123ea0b 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -44,6 +44,7 @@ from black import Feature, TargetVersion from black import re_compile_maybe_verbose as compile_pattern from black.cache import FileData, get_cache_dir, get_cache_file from black.debug import DebugVisitor +from black.mode import Mode, Preview from black.output import color_diff, diff from black.report import Report @@ -2065,6 +2066,30 @@ class TestCaching: monkeypatch.setenv("BLACK_CACHE_DIR", str(workspace2)) assert get_cache_dir().parent == workspace2 + def test_cache_file_length(self) -> None: + cases = [ + DEFAULT_MODE, + # all of the target versions + Mode(target_versions=set(TargetVersion)), + # all of the features + Mode(enabled_features=set(Preview)), + # all of the magics + Mode(python_cell_magics={f"magic{i}" for i in range(500)}), + # all of the things + Mode( + target_versions=set(TargetVersion), + enabled_features=set(Preview), + python_cell_magics={f"magic{i}" for i in range(500)}, + ), + ] + for case in cases: + cache_file = get_cache_file(case) + # Some common file systems enforce a maximum path length + # of 143 (issue #4174). We can't do anything if the directory + # path is too long, but ensure the name of the cache file itself + # doesn't get too crazy. + assert len(cache_file.name) <= 96 + def test_cache_broken_file(self) -> None: mode = DEFAULT_MODE with cache_dir() as workspace:
cache uses filenames that might be too long on some systems **Describe the bug** Running black 24.1.0 (without --check) can produce filenames in user's cache folder that are too long for some filesystems e.g. eCryptFS only allows filenames that are 143 chars long The resulting error is: ``` Traceback (most recent call last): File "/home/hottwaj/.pyenv/versions/3.10.2/envs/test-venv/bin/black", line 8, in <module> sys.exit(patched_main()) File "src/black/__init__.py", line 1593, in patched_main File "/home/hottwaj/.pyenv/versions/3.10.2/envs/test-venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) File "/home/hottwaj/.pyenv/versions/3.10.2/envs/test-venv/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/home/hottwaj/.pyenv/versions/3.10.2/envs/test-venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/hottwaj/.pyenv/versions/3.10.2/envs/test-venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/home/hottwaj/.pyenv/versions/3.10.2/envs/test-venv/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), *args, **kwargs) File "src/black/__init__.py", line 703, in main File "/home/hottwaj/.pyenv/versions/3.10.2/envs/test-venv/lib/python3.10/site-packages/black/concurrency.py", line 101, in reformat_many loop.run_until_complete( File "/home/hottwaj/.pyenv/versions/3.10.2/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete return future.result() File "/home/hottwaj/.pyenv/versions/3.10.2/envs/test-venv/lib/python3.10/site-packages/black/concurrency.py", line 137, in schedule_formatting cache = Cache.read(mode) File "src/black/cache.py", line 67, in read File "/home/hottwaj/.pyenv/versions/3.10.2/lib/python3.10/pathlib.py", line 1288, in exists self.stat() File "/home/hottwaj/.pyenv/versions/3.10.2/lib/python3.10/pathlib.py", line 1095, in stat return self._accessor.stat(self, follow_symlinks=follow_symlinks) OSError: [Errno 36] File name too long: '/home/hottwaj/.cache/black/24.1.0/cache.-.130.0.0.0.0.1.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.0.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.pickle' ``` **Environment** <!-- Please complete the following information: --> - Black's version: 24.1.0 - OS and Python version: Linux, Python 3.10.2, home folder encrypted with eCryptFS
0.0
659c29a41c7c686687aef21f57b95bcfa236b03b
[ "tests/test_black.py::TestCaching::test_cache_file_length" ]
[ "tests/test_black.py::BlackTestCase::test_assertFormatEqual_print_full_tree", "tests/test_black.py::BlackTestCase::test_assertFormatEqual_print_tree_diff", "tests/test_black.py::BlackTestCase::test_assert_equivalent_different_asts", "tests/test_black.py::BlackTestCase::test_async_as_identifier", "tests/test_black.py::BlackTestCase::test_bpo_2142_workaround", "tests/test_black.py::BlackTestCase::test_bpo_33660_workaround", "tests/test_black.py::BlackTestCase::test_broken_symlink", "tests/test_black.py::BlackTestCase::test_check_diff_use_together", "tests/test_black.py::BlackTestCase::test_cli_unstable", "tests/test_black.py::BlackTestCase::test_code_option", "tests/test_black.py::BlackTestCase::test_code_option_changed", "tests/test_black.py::BlackTestCase::test_code_option_check", "tests/test_black.py::BlackTestCase::test_code_option_check_changed", "tests/test_black.py::BlackTestCase::test_code_option_color_diff", "tests/test_black.py::BlackTestCase::test_code_option_config", "tests/test_black.py::BlackTestCase::test_code_option_diff", "tests/test_black.py::BlackTestCase::test_code_option_fast", "tests/test_black.py::BlackTestCase::test_code_option_parent_config", "tests/test_black.py::BlackTestCase::test_code_option_safe", "tests/test_black.py::BlackTestCase::test_debug_visitor", "tests/test_black.py::BlackTestCase::test_detect_debug_f_strings", "tests/test_black.py::BlackTestCase::test_detect_pos_only_arguments", "tests/test_black.py::BlackTestCase::test_empty_ff", "tests/test_black.py::BlackTestCase::test_endmarker", "tests/test_black.py::BlackTestCase::test_equivalency_ast_parse_failure_includes_error", "tests/test_black.py::BlackTestCase::test_expression_diff", "tests/test_black.py::BlackTestCase::test_expression_diff_with_color", "tests/test_black.py::BlackTestCase::test_expression_ff", "tests/test_black.py::BlackTestCase::test_false_positive_symlink_output_issue_3384", "tests/test_black.py::BlackTestCase::test_find_project_root", "tests/test_black.py::BlackTestCase::test_find_pyproject_toml", "tests/test_black.py::BlackTestCase::test_find_user_pyproject_toml_linux", "tests/test_black.py::BlackTestCase::test_find_user_pyproject_toml_windows", "tests/test_black.py::BlackTestCase::test_for_handled_unexpected_eof_error", "tests/test_black.py::BlackTestCase::test_format_file_contents", "tests/test_black.py::BlackTestCase::test_get_features_used", "tests/test_black.py::BlackTestCase::test_get_features_used_decorator", "tests/test_black.py::BlackTestCase::test_get_features_used_for_future_flags", "tests/test_black.py::BlackTestCase::test_get_future_imports", "tests/test_black.py::BlackTestCase::test_infer_target_version", "tests/test_black.py::BlackTestCase::test_invalid_cli_regex", "tests/test_black.py::BlackTestCase::test_invalid_config_return_code", "tests/test_black.py::BlackTestCase::test_lib2to3_parse", "tests/test_black.py::BlackTestCase::test_line_ranges_in_pyproject_toml", "tests/test_black.py::BlackTestCase::test_line_ranges_with_code_option", "tests/test_black.py::BlackTestCase::test_line_ranges_with_ipynb", "tests/test_black.py::BlackTestCase::test_line_ranges_with_multiple_sources", "tests/test_black.py::BlackTestCase::test_line_ranges_with_source", "tests/test_black.py::BlackTestCase::test_line_ranges_with_stdin", "tests/test_black.py::BlackTestCase::test_multi_file_force_py36", "tests/test_black.py::BlackTestCase::test_multi_file_force_pyi", "tests/test_black.py::BlackTestCase::test_newline_comment_interaction", "tests/test_black.py::BlackTestCase::test_no_src_fails", "tests/test_black.py::BlackTestCase::test_normalize_line_endings", "tests/test_black.py::BlackTestCase::test_normalize_path_ignore_windows_junctions_outside_of_root", "tests/test_black.py::BlackTestCase::test_one_empty_line", "tests/test_black.py::BlackTestCase::test_one_empty_line_ff", "tests/test_black.py::BlackTestCase::test_parse_pyproject_toml", "tests/test_black.py::BlackTestCase::test_parse_pyproject_toml_project_metadata", "tests/test_black.py::BlackTestCase::test_pep_572_version_detection", "tests/test_black.py::BlackTestCase::test_pep_695_version_detection", "tests/test_black.py::BlackTestCase::test_pipe_force_py36", "tests/test_black.py::BlackTestCase::test_pipe_force_pyi", "tests/test_black.py::BlackTestCase::test_piping", "tests/test_black.py::BlackTestCase::test_piping_diff", "tests/test_black.py::BlackTestCase::test_piping_diff_with_color", "tests/test_black.py::BlackTestCase::test_preserves_line_endings", "tests/test_black.py::BlackTestCase::test_preserves_line_endings_via_stdin", "tests/test_black.py::BlackTestCase::test_python37", "tests/test_black.py::BlackTestCase::test_read_pyproject_toml", "tests/test_black.py::BlackTestCase::test_read_pyproject_toml_from_stdin", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_and_existing_path", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_empty", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename_ipynb", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename_pyi", "tests/test_black.py::BlackTestCase::test_report_normal", "tests/test_black.py::BlackTestCase::test_report_quiet", "tests/test_black.py::BlackTestCase::test_report_verbose", "tests/test_black.py::BlackTestCase::test_required_version_does_not_match_on_minor_version", "tests/test_black.py::BlackTestCase::test_required_version_does_not_match_version", "tests/test_black.py::BlackTestCase::test_required_version_matches_partial_version", "tests/test_black.py::BlackTestCase::test_required_version_matches_version", "tests/test_black.py::BlackTestCase::test_root_logger_not_used_directly", "tests/test_black.py::BlackTestCase::test_single_file_force_py36", "tests/test_black.py::BlackTestCase::test_single_file_force_pyi", "tests/test_black.py::BlackTestCase::test_skip_magic_trailing_comma", "tests/test_black.py::BlackTestCase::test_skip_source_first_line", "tests/test_black.py::BlackTestCase::test_skip_source_first_line_when_mixing_newlines", "tests/test_black.py::BlackTestCase::test_spellcheck_pyproject_toml", "tests/test_black.py::BlackTestCase::test_src_and_code_fails", "tests/test_black.py::BlackTestCase::test_string_quotes", "tests/test_black.py::BlackTestCase::test_tab_comment_indentation", "tests/test_black.py::BlackTestCase::test_works_in_mono_process_only_environment", "tests/test_black.py::TestCaching::test_get_cache_dir", "tests/test_black.py::TestCaching::test_cache_broken_file", "tests/test_black.py::TestCaching::test_cache_single_file_already_cached", "tests/test_black.py::TestCaching::test_cache_multiple_files", "tests/test_black.py::TestCaching::test_no_cache_when_writeback_diff[no-color]", "tests/test_black.py::TestCaching::test_no_cache_when_writeback_diff[with-color]", "tests/test_black.py::TestCaching::test_output_locking_when_writeback_diff[no-color]", "tests/test_black.py::TestCaching::test_output_locking_when_writeback_diff[with-color]", "tests/test_black.py::TestCaching::test_no_cache_when_stdin", "tests/test_black.py::TestCaching::test_read_cache_no_cachefile", "tests/test_black.py::TestCaching::test_write_cache_read_cache", "tests/test_black.py::TestCaching::test_filter_cached", "tests/test_black.py::TestCaching::test_filter_cached_hash", "tests/test_black.py::TestCaching::test_write_cache_creates_directory_if_needed", "tests/test_black.py::TestCaching::test_failed_formatting_does_not_get_cached", "tests/test_black.py::TestCaching::test_write_cache_write_fail", "tests/test_black.py::TestCaching::test_read_cache_line_lengths", "tests/test_black.py::TestFileCollection::test_include_exclude", "tests/test_black.py::TestFileCollection::test_gitignore_used_as_default", "tests/test_black.py::TestFileCollection::test_gitignore_used_on_multiple_sources", "tests/test_black.py::TestFileCollection::test_exclude_for_issue_1572", "tests/test_black.py::TestFileCollection::test_gitignore_exclude", "tests/test_black.py::TestFileCollection::test_nested_gitignore", "tests/test_black.py::TestFileCollection::test_nested_gitignore_directly_in_source_directory", "tests/test_black.py::TestFileCollection::test_invalid_gitignore", "tests/test_black.py::TestFileCollection::test_invalid_nested_gitignore", "tests/test_black.py::TestFileCollection::test_gitignore_that_ignores_subfolders", "tests/test_black.py::TestFileCollection::test_empty_include", "tests/test_black.py::TestFileCollection::test_include_absolute_path", "tests/test_black.py::TestFileCollection::test_exclude_absolute_path", "tests/test_black.py::TestFileCollection::test_extend_exclude", "tests/test_black.py::TestFileCollection::test_symlinks", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_symlink_outside_root", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_extend_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_force_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_force_exclude_and_symlink", "tests/test_black.py::TestDeFactoAPI::test_format_str", "tests/test_black.py::TestDeFactoAPI::test_format_file_contents" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2024-01-26 15:38:51+00:00
mit
4,703
psf__black-4270
diff --git a/CHANGES.md b/CHANGES.md index e28730a..1d20a4c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,10 @@ <!-- Changes that affect Black's stable style --> - Don't move comments along with delimiters, which could cause crashes (#4248) +- Strengthen AST safety check to catch more unsafe changes to strings. Previous versions + of Black would incorrectly format the contents of certain unusual f-strings containing + nested strings with the same quote type. Now, Black will crash on such strings until + support for the new f-string syntax is implemented. (#4270) ### Preview style diff --git a/src/black/__init__.py b/src/black/__init__.py index f82b9fe..da884e6 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -77,8 +77,13 @@ from black.nodes import ( syms, ) from black.output import color_diff, diff, dump_to_file, err, ipynb_diff, out -from black.parsing import InvalidInput # noqa F401 -from black.parsing import lib2to3_parse, parse_ast, stringify_ast +from black.parsing import ( # noqa F401 + ASTSafetyError, + InvalidInput, + lib2to3_parse, + parse_ast, + stringify_ast, +) from black.ranges import adjusted_lines, convert_unchanged_lines, parse_line_ranges from black.report import Changed, NothingChanged, Report from black.trans import iter_fexpr_spans @@ -1511,7 +1516,7 @@ def assert_equivalent(src: str, dst: str) -> None: try: src_ast = parse_ast(src) except Exception as exc: - raise AssertionError( + raise ASTSafetyError( "cannot use --safe with this file; failed to parse source file AST: " f"{exc}\n" "This could be caused by running Black with an older Python version " @@ -1522,7 +1527,7 @@ def assert_equivalent(src: str, dst: str) -> None: dst_ast = parse_ast(dst) except Exception as exc: log = dump_to_file("".join(traceback.format_tb(exc.__traceback__)), dst) - raise AssertionError( + raise ASTSafetyError( f"INTERNAL ERROR: Black produced invalid code: {exc}. " "Please report a bug on https://github.com/psf/black/issues. " f"This invalid output might be helpful: {log}" @@ -1532,7 +1537,7 @@ def assert_equivalent(src: str, dst: str) -> None: dst_ast_str = "\n".join(stringify_ast(dst_ast)) if src_ast_str != dst_ast_str: log = dump_to_file(diff(src_ast_str, dst_ast_str, "src", "dst")) - raise AssertionError( + raise ASTSafetyError( "INTERNAL ERROR: Black produced code that is not equivalent to the" " source. Please report a bug on " f"https://github.com/psf/black/issues. This diff might be helpful: {log}" diff --git a/src/black/parsing.py b/src/black/parsing.py index 63c5e71..aa97a8c 100644 --- a/src/black/parsing.py +++ b/src/black/parsing.py @@ -110,6 +110,10 @@ def lib2to3_unparse(node: Node) -> str: return code +class ASTSafetyError(Exception): + """Raised when Black's generated code is not equivalent to the old AST.""" + + def _parse_single_version( src: str, version: Tuple[int, int], *, type_comments: bool ) -> ast.AST: @@ -154,9 +158,20 @@ def _normalize(lineend: str, value: str) -> str: return normalized.strip() -def stringify_ast(node: ast.AST, depth: int = 0) -> Iterator[str]: +def stringify_ast(node: ast.AST) -> Iterator[str]: """Simple visitor generating strings to compare ASTs by content.""" + return _stringify_ast(node, []) + +def _stringify_ast_with_new_parent( + node: ast.AST, parent_stack: List[ast.AST], new_parent: ast.AST +) -> Iterator[str]: + parent_stack.append(new_parent) + yield from _stringify_ast(node, parent_stack) + parent_stack.pop() + + +def _stringify_ast(node: ast.AST, parent_stack: List[ast.AST]) -> Iterator[str]: if ( isinstance(node, ast.Constant) and isinstance(node.value, str) @@ -167,7 +182,7 @@ def stringify_ast(node: ast.AST, depth: int = 0) -> Iterator[str]: # over the kind node.kind = None - yield f"{' ' * depth}{node.__class__.__name__}(" + yield f"{' ' * len(parent_stack)}{node.__class__.__name__}(" for field in sorted(node._fields): # noqa: F402 # TypeIgnore has only one field 'lineno' which breaks this comparison @@ -179,7 +194,7 @@ def stringify_ast(node: ast.AST, depth: int = 0) -> Iterator[str]: except AttributeError: continue - yield f"{' ' * (depth + 1)}{field}=" + yield f"{' ' * (len(parent_stack) + 1)}{field}=" if isinstance(value, list): for item in value: @@ -191,13 +206,15 @@ def stringify_ast(node: ast.AST, depth: int = 0) -> Iterator[str]: and isinstance(item, ast.Tuple) ): for elt in item.elts: - yield from stringify_ast(elt, depth + 2) + yield from _stringify_ast_with_new_parent( + elt, parent_stack, node + ) elif isinstance(item, ast.AST): - yield from stringify_ast(item, depth + 2) + yield from _stringify_ast_with_new_parent(item, parent_stack, node) elif isinstance(value, ast.AST): - yield from stringify_ast(value, depth + 2) + yield from _stringify_ast_with_new_parent(value, parent_stack, node) else: normalized: object @@ -205,6 +222,12 @@ def stringify_ast(node: ast.AST, depth: int = 0) -> Iterator[str]: isinstance(node, ast.Constant) and field == "value" and isinstance(value, str) + and len(parent_stack) >= 2 + and isinstance(parent_stack[-1], ast.Expr) + and isinstance( + parent_stack[-2], + (ast.FunctionDef, ast.AsyncFunctionDef, ast.Module, ast.ClassDef), + ) ): # Constant strings may be indented across newlines, if they are # docstrings; fold spaces after newlines when comparing. Similarly, @@ -215,6 +238,9 @@ def stringify_ast(node: ast.AST, depth: int = 0) -> Iterator[str]: normalized = value.rstrip() else: normalized = value - yield f"{' ' * (depth + 2)}{normalized!r}, # {value.__class__.__name__}" + yield ( + f"{' ' * (len(parent_stack) + 1)}{normalized!r}, #" + f" {value.__class__.__name__}" + ) - yield f"{' ' * depth}) # /{node.__class__.__name__}" + yield f"{' ' * len(parent_stack)}) # /{node.__class__.__name__}"
psf/black
f03ee113c9f3dfeb477f2d4247bfb7de2e5f465c
diff --git a/tests/test_black.py b/tests/test_black.py index 41f87cd..96f53d5 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -46,6 +46,7 @@ from black.cache import FileData, get_cache_dir, get_cache_file from black.debug import DebugVisitor from black.mode import Mode, Preview from black.output import color_diff, diff +from black.parsing import ASTSafetyError from black.report import Report # Import other test classes @@ -1473,10 +1474,6 @@ class BlackTestCase(BlackBaseTestCase): ff(test_file, write_back=black.WriteBack.YES) self.assertEqual(test_file.read_bytes(), expected) - def test_assert_equivalent_different_asts(self) -> None: - with self.assertRaises(AssertionError): - black.assert_equivalent("{}", "None") - def test_root_logger_not_used_directly(self) -> None: def fail(*args: Any, **kwargs: Any) -> None: self.fail("Record created with root logger") @@ -1962,16 +1959,6 @@ class BlackTestCase(BlackBaseTestCase): exc_info.match("Cannot parse: 2:0: EOF in multi-line statement") - def test_equivalency_ast_parse_failure_includes_error(self) -> None: - with pytest.raises(AssertionError) as err: - black.assert_equivalent("a«»a = 1", "a«»a = 1") - - err.match("--safe") - # Unfortunately the SyntaxError message has changed in newer versions so we - # can't match it directly. - err.match("invalid character") - err.match(r"\(<unknown>, line 1\)") - def test_line_ranges_with_code_option(self) -> None: code = textwrap.dedent("""\ if a == b: @@ -2822,6 +2809,113 @@ class TestDeFactoAPI: black.format_file_contents("x = 1\n", fast=True, mode=black.Mode()) +class TestASTSafety(BlackBaseTestCase): + def check_ast_equivalence( + self, source: str, dest: str, *, should_fail: bool = False + ) -> None: + # If we get a failure, make sure it's not because the code itself + # is invalid, since that will also cause assert_equivalent() to throw + # ASTSafetyError. + source = textwrap.dedent(source) + dest = textwrap.dedent(dest) + black.parse_ast(source) + black.parse_ast(dest) + if should_fail: + with self.assertRaises(ASTSafetyError): + black.assert_equivalent(source, dest) + else: + black.assert_equivalent(source, dest) + + def test_assert_equivalent_basic(self) -> None: + self.check_ast_equivalence("{}", "None", should_fail=True) + self.check_ast_equivalence("1+2", "1 + 2") + self.check_ast_equivalence("hi # comment", "hi") + + def test_assert_equivalent_del(self) -> None: + self.check_ast_equivalence("del (a, b)", "del a, b") + + def test_assert_equivalent_strings(self) -> None: + self.check_ast_equivalence('x = "x"', 'x = " x "', should_fail=True) + self.check_ast_equivalence( + ''' + """docstring """ + ''', + ''' + """docstring""" + ''', + ) + self.check_ast_equivalence( + ''' + """docstring """ + ''', + ''' + """ddocstring""" + ''', + should_fail=True, + ) + self.check_ast_equivalence( + ''' + class A: + """ + + docstring + + + """ + ''', + ''' + class A: + """docstring""" + ''', + ) + self.check_ast_equivalence( + """ + def f(): + " docstring " + """, + ''' + def f(): + """docstring""" + ''', + ) + self.check_ast_equivalence( + """ + async def f(): + " docstring " + """, + ''' + async def f(): + """docstring""" + ''', + ) + + def test_assert_equivalent_fstring(self) -> None: + major, minor = sys.version_info[:2] + if major < 3 or (major == 3 and minor < 12): + pytest.skip("relies on 3.12+ syntax") + # https://github.com/psf/black/issues/4268 + self.check_ast_equivalence( + """print(f"{"|".join([a,b,c])}")""", + """print(f"{" | ".join([a,b,c])}")""", + should_fail=True, + ) + self.check_ast_equivalence( + """print(f"{"|".join(['a','b','c'])}")""", + """print(f"{" | ".join(['a','b','c'])}")""", + should_fail=True, + ) + + def test_equivalency_ast_parse_failure_includes_error(self) -> None: + with pytest.raises(ASTSafetyError) as err: + black.assert_equivalent("a«»a = 1", "a«»a = 1") + + err.match("--safe") + # Unfortunately the SyntaxError message has changed in newer versions so we + # can't match it directly. + err.match("invalid character") + err.match(r"\(<unknown>, line 1\)") + + try: with open(black.__file__, "r", encoding="utf-8") as _bf: black_source_lines = _bf.readlines()
AST safety check fails to catch incorrect f-string change **Describe the style change** I wonder if f-strings should be formatted at all. **Examples in the current _Black_ style** ```python print(f"{"|".join(['a','b','c'])}") ``` **Desired style** ```python print(f"{"|".join(['a','b','c'])}") ``` > [!NOTE] > There's no change to the input here. **Additional context** Black formats the `"|"` to become `" | "` and that affects the output which cannot be desired. Black formats the snippet like this currently: ```python print(f"{" | ".join(['a','b','c'])}") ```
0.0
f03ee113c9f3dfeb477f2d4247bfb7de2e5f465c
[ "tests/test_black.py::BlackTestCase::test_assertFormatEqual_print_full_tree", "tests/test_black.py::BlackTestCase::test_assertFormatEqual_print_tree_diff", "tests/test_black.py::BlackTestCase::test_async_as_identifier", "tests/test_black.py::BlackTestCase::test_bpo_2142_workaround", "tests/test_black.py::BlackTestCase::test_bpo_33660_workaround", "tests/test_black.py::BlackTestCase::test_broken_symlink", "tests/test_black.py::BlackTestCase::test_check_diff_use_together", "tests/test_black.py::BlackTestCase::test_cli_unstable", "tests/test_black.py::BlackTestCase::test_code_option", "tests/test_black.py::BlackTestCase::test_code_option_changed", "tests/test_black.py::BlackTestCase::test_code_option_check", "tests/test_black.py::BlackTestCase::test_code_option_check_changed", "tests/test_black.py::BlackTestCase::test_code_option_color_diff", "tests/test_black.py::BlackTestCase::test_code_option_config", "tests/test_black.py::BlackTestCase::test_code_option_diff", "tests/test_black.py::BlackTestCase::test_code_option_fast", "tests/test_black.py::BlackTestCase::test_code_option_parent_config", "tests/test_black.py::BlackTestCase::test_code_option_safe", "tests/test_black.py::BlackTestCase::test_debug_visitor", "tests/test_black.py::BlackTestCase::test_detect_debug_f_strings", "tests/test_black.py::BlackTestCase::test_detect_pos_only_arguments", "tests/test_black.py::BlackTestCase::test_empty_ff", "tests/test_black.py::BlackTestCase::test_endmarker", "tests/test_black.py::BlackTestCase::test_expression_diff", "tests/test_black.py::BlackTestCase::test_expression_diff_with_color", "tests/test_black.py::BlackTestCase::test_expression_ff", "tests/test_black.py::BlackTestCase::test_false_positive_symlink_output_issue_3384", "tests/test_black.py::BlackTestCase::test_find_project_root", "tests/test_black.py::BlackTestCase::test_find_pyproject_toml", "tests/test_black.py::BlackTestCase::test_find_user_pyproject_toml_linux", "tests/test_black.py::BlackTestCase::test_find_user_pyproject_toml_windows", "tests/test_black.py::BlackTestCase::test_for_handled_unexpected_eof_error", "tests/test_black.py::BlackTestCase::test_format_file_contents", "tests/test_black.py::BlackTestCase::test_get_features_used", "tests/test_black.py::BlackTestCase::test_get_features_used_decorator", "tests/test_black.py::BlackTestCase::test_get_features_used_for_future_flags", "tests/test_black.py::BlackTestCase::test_get_future_imports", "tests/test_black.py::BlackTestCase::test_infer_target_version", "tests/test_black.py::BlackTestCase::test_invalid_cli_regex", "tests/test_black.py::BlackTestCase::test_invalid_config_return_code", "tests/test_black.py::BlackTestCase::test_lib2to3_parse", "tests/test_black.py::BlackTestCase::test_line_ranges_in_pyproject_toml", "tests/test_black.py::BlackTestCase::test_line_ranges_with_code_option", "tests/test_black.py::BlackTestCase::test_line_ranges_with_ipynb", "tests/test_black.py::BlackTestCase::test_line_ranges_with_multiple_sources", "tests/test_black.py::BlackTestCase::test_line_ranges_with_source", "tests/test_black.py::BlackTestCase::test_line_ranges_with_stdin", "tests/test_black.py::BlackTestCase::test_multi_file_force_py36", "tests/test_black.py::BlackTestCase::test_multi_file_force_pyi", "tests/test_black.py::BlackTestCase::test_newline_comment_interaction", "tests/test_black.py::BlackTestCase::test_no_src_fails", "tests/test_black.py::BlackTestCase::test_normalize_line_endings", "tests/test_black.py::BlackTestCase::test_normalize_path_ignore_windows_junctions_outside_of_root", "tests/test_black.py::BlackTestCase::test_one_empty_line", "tests/test_black.py::BlackTestCase::test_one_empty_line_ff", "tests/test_black.py::BlackTestCase::test_parse_pyproject_toml", "tests/test_black.py::BlackTestCase::test_parse_pyproject_toml_project_metadata", "tests/test_black.py::BlackTestCase::test_pep_572_version_detection", "tests/test_black.py::BlackTestCase::test_pep_695_version_detection", "tests/test_black.py::BlackTestCase::test_pipe_force_py36", "tests/test_black.py::BlackTestCase::test_pipe_force_pyi", "tests/test_black.py::BlackTestCase::test_piping", "tests/test_black.py::BlackTestCase::test_piping_diff", "tests/test_black.py::BlackTestCase::test_piping_diff_with_color", "tests/test_black.py::BlackTestCase::test_preserves_line_endings", "tests/test_black.py::BlackTestCase::test_preserves_line_endings_via_stdin", "tests/test_black.py::BlackTestCase::test_python37", "tests/test_black.py::BlackTestCase::test_read_pyproject_toml", "tests/test_black.py::BlackTestCase::test_read_pyproject_toml_from_stdin", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_and_existing_path", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_empty", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename_ipynb", "tests/test_black.py::BlackTestCase::test_reformat_one_with_stdin_filename_pyi", "tests/test_black.py::BlackTestCase::test_report_normal", "tests/test_black.py::BlackTestCase::test_report_quiet", "tests/test_black.py::BlackTestCase::test_report_verbose", "tests/test_black.py::BlackTestCase::test_required_version_does_not_match_on_minor_version", "tests/test_black.py::BlackTestCase::test_required_version_does_not_match_version", "tests/test_black.py::BlackTestCase::test_required_version_matches_partial_version", "tests/test_black.py::BlackTestCase::test_required_version_matches_version", "tests/test_black.py::BlackTestCase::test_root_logger_not_used_directly", "tests/test_black.py::BlackTestCase::test_single_file_force_py36", "tests/test_black.py::BlackTestCase::test_single_file_force_pyi", "tests/test_black.py::BlackTestCase::test_skip_magic_trailing_comma", "tests/test_black.py::BlackTestCase::test_skip_source_first_line", "tests/test_black.py::BlackTestCase::test_skip_source_first_line_when_mixing_newlines", "tests/test_black.py::BlackTestCase::test_spellcheck_pyproject_toml", "tests/test_black.py::BlackTestCase::test_src_and_code_fails", "tests/test_black.py::BlackTestCase::test_string_quotes", "tests/test_black.py::BlackTestCase::test_tab_comment_indentation", "tests/test_black.py::BlackTestCase::test_works_in_mono_process_only_environment", "tests/test_black.py::TestCaching::test_get_cache_dir", "tests/test_black.py::TestCaching::test_cache_file_length", "tests/test_black.py::TestCaching::test_cache_broken_file", "tests/test_black.py::TestCaching::test_cache_single_file_already_cached", "tests/test_black.py::TestCaching::test_cache_multiple_files", "tests/test_black.py::TestCaching::test_no_cache_when_writeback_diff[no-color]", "tests/test_black.py::TestCaching::test_no_cache_when_writeback_diff[with-color]", "tests/test_black.py::TestCaching::test_output_locking_when_writeback_diff[no-color]", "tests/test_black.py::TestCaching::test_output_locking_when_writeback_diff[with-color]", "tests/test_black.py::TestCaching::test_no_cache_when_stdin", "tests/test_black.py::TestCaching::test_read_cache_no_cachefile", "tests/test_black.py::TestCaching::test_write_cache_read_cache", "tests/test_black.py::TestCaching::test_filter_cached", "tests/test_black.py::TestCaching::test_filter_cached_hash", "tests/test_black.py::TestCaching::test_write_cache_creates_directory_if_needed", "tests/test_black.py::TestCaching::test_failed_formatting_does_not_get_cached", "tests/test_black.py::TestCaching::test_write_cache_write_fail", "tests/test_black.py::TestCaching::test_read_cache_line_lengths", "tests/test_black.py::TestFileCollection::test_include_exclude", "tests/test_black.py::TestFileCollection::test_gitignore_used_as_default", "tests/test_black.py::TestFileCollection::test_gitignore_used_on_multiple_sources", "tests/test_black.py::TestFileCollection::test_exclude_for_issue_1572", "tests/test_black.py::TestFileCollection::test_gitignore_exclude", "tests/test_black.py::TestFileCollection::test_nested_gitignore", "tests/test_black.py::TestFileCollection::test_nested_gitignore_directly_in_source_directory", "tests/test_black.py::TestFileCollection::test_invalid_gitignore", "tests/test_black.py::TestFileCollection::test_invalid_nested_gitignore", "tests/test_black.py::TestFileCollection::test_gitignore_that_ignores_subfolders", "tests/test_black.py::TestFileCollection::test_empty_include", "tests/test_black.py::TestFileCollection::test_include_absolute_path", "tests/test_black.py::TestFileCollection::test_exclude_absolute_path", "tests/test_black.py::TestFileCollection::test_extend_exclude", "tests/test_black.py::TestFileCollection::test_symlinks", "tests/test_black.py::TestFileCollection::test_get_sources_symlink_and_force_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_symlink_outside_root", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_extend_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_force_exclude", "tests/test_black.py::TestFileCollection::test_get_sources_with_stdin_filename_and_force_exclude_and_symlink", "tests/test_black.py::TestDeFactoAPI::test_format_str", "tests/test_black.py::TestDeFactoAPI::test_format_file_contents", "tests/test_black.py::TestASTSafety::test_assert_equivalent_basic", "tests/test_black.py::TestASTSafety::test_assert_equivalent_del", "tests/test_black.py::TestASTSafety::test_assert_equivalent_strings", "tests/test_black.py::TestASTSafety::test_equivalency_ast_parse_failure_includes_error" ]
[]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks", "has_pytest_match_arg" ], "has_test_patch": true, "is_lite": false }
2024-03-09 15:14:59+00:00
mit
4,704
pyasi__pybuildkite-70
diff --git a/pybuildkite/buildkite.py b/pybuildkite/buildkite.py index c89d8bd..1fd44b1 100644 --- a/pybuildkite/buildkite.py +++ b/pybuildkite/buildkite.py @@ -9,6 +9,7 @@ from pybuildkite.annotations import Annotations from pybuildkite.artifacts import Artifacts from pybuildkite.teams import Teams from pybuildkite.users import Users +from pybuildkite.meta import Meta from pybuildkite.decorators import requires_token @@ -110,3 +111,11 @@ class Buildkite(object): Get User operations for the Buildkite API """ return Users(self.client, self.base_url) + + def meta(self): + """ + Get Meta operations for the Buildkite API + + :return: Client + """ + return Meta(self.client, self.base_url) diff --git a/pybuildkite/meta.py b/pybuildkite/meta.py new file mode 100644 index 0000000..10f7333 --- /dev/null +++ b/pybuildkite/meta.py @@ -0,0 +1,27 @@ +from posixpath import join as urljoin + +from pybuildkite.client import Client + + +class Meta(Client): + """ + Meta operations for the Buildkite API + """ + + def __init__(self, client, base_url): + """ + Construct the class + + :param client: API Client + :param base_url: Base Url + """ + self.client = client + self.path = urljoin(base_url, "meta") + + def get_meta_information(self): + """ + Returns meta information + + :return: Returns meta information + """ + return self.client.get(self.path) diff --git a/requirements.txt b/requirements.txt index 0fda20c..b64cfd9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ mock==3.0.5 coveralls==2.0.0 pytest==5.2.1 pytest-cov==2.8.1 -requests==2.22.0 +requests==2.26.0 urllib3==1.26.5 black==19.3b0 typing-extensions==3.7.4.2
pyasi/pybuildkite
fa356015ec0780a4fbd4cfa7f9c63f01590301b8
diff --git a/tests/test_buildkite.py b/tests/test_buildkite.py index 5bb9d1a..6f5e1db 100644 --- a/tests/test_buildkite.py +++ b/tests/test_buildkite.py @@ -11,6 +11,7 @@ from pybuildkite.buildkite import ( Teams, Users, Organizations, + Meta, ) from pybuildkite.exceptions import NoAcccessTokenException @@ -46,6 +47,7 @@ def test_access_token_set(): (Buildkite().users, Users), (Buildkite().annotations, Annotations), (Buildkite().organizations, Organizations), + (Buildkite().meta, Meta), ], ) def test_eval(function, expected_type): diff --git a/tests/test_meta.py b/tests/test_meta.py new file mode 100644 index 0000000..fff0d8c --- /dev/null +++ b/tests/test_meta.py @@ -0,0 +1,10 @@ +from pybuildkite.meta import Meta + + +def test_get_meta_information(fake_client): + """ + Test get user + """ + meta = Meta(fake_client, "https://api.buildkite.com/v2/") + meta.get_meta_information() + fake_client.get.assert_called_with(meta.path) diff --git a/tests/test_pipelines.py b/tests/test_pipelines.py index 4e55fab..c4126de 100644 --- a/tests/test_pipelines.py +++ b/tests/test_pipelines.py @@ -51,6 +51,7 @@ def test_create_pipeline(fake_client): "command": "buildkite-agent pipeline upload", } ], + "team_uuids": None, } ) @@ -86,6 +87,7 @@ def test_create_yaml_pipeline(fake_client): "name": "test_pipeline", "repository": "my_repo", "configuration": "steps:\n - command: ls", + "team_uuids": None, }, )
Create functionality for the 'meta' endpoint Create a new file and class to incorporate the [meta API](https://buildkite.com/docs/apis/rest-api/meta). - Create a new file called `meta.py` - Create a class called Meta - Return the Meta class from a method in [buildkite.py](https://github.com/pyasi/pybuildkite/blob/master/pybuildkite/buildkite.py) - Write unit tests for the new code
0.0
fa356015ec0780a4fbd4cfa7f9c63f01590301b8
[ "tests/test_buildkite.py::test_access_token_not_set_raises_exception", "tests/test_buildkite.py::test_access_token_set", "tests/test_buildkite.py::test_eval[wrapper-Pipelines]", "tests/test_buildkite.py::test_eval[wrapper-Builds]", "tests/test_buildkite.py::test_eval[wrapper-Jobs]", "tests/test_buildkite.py::test_eval[wrapper-Agents]", "tests/test_buildkite.py::test_eval[wrapper-Emojis]", "tests/test_buildkite.py::test_eval[wrapper-Artifacts]", "tests/test_buildkite.py::test_eval[wrapper-Teams]", "tests/test_buildkite.py::test_eval[wrapper-Users]", "tests/test_buildkite.py::test_eval[wrapper-Annotations]", "tests/test_buildkite.py::test_eval[wrapper-Organizations]", "tests/test_buildkite.py::test_eval[meta-Meta]", "tests/test_meta.py::test_get_meta_information", "tests/test_pipelines.py::test_Pipelines", "tests/test_pipelines.py::test_list_pipelines", "tests/test_pipelines.py::test_get_pipeline", "tests/test_pipelines.py::test_create_pipeline", "tests/test_pipelines.py::test_create_pipeline_with_teams", "tests/test_pipelines.py::test_create_yaml_pipeline", "tests/test_pipelines.py::test_create_yaml_pipeline_with_teams", "tests/test_pipelines.py::test_delete_pipeline", "tests/test_pipelines.py::test_update_pipeline", "tests/test_pipelines.py::test_update_pipeline_configuration_and_steps" ]
[]
{ "failed_lite_validators": [ "has_hyperlinks", "has_added_files", "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2021-10-02 00:50:01+00:00
bsd-2-clause
4,705
pybamm-team__PyBaMM-3968
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fc8e848bb..aeb62b9b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -126,26 +126,18 @@ This allows people to (1) use PyBaMM without importing optional dependencies by **Writing Tests for Optional Dependencies** -Whenever a new optional dependency is added for optional functionality, it is recommended to write a corresponding unit test in `test_util.py`. This ensures that an error is raised upon the absence of said dependency. Here's an example: +Below, we list the currently available test functions to provide an overview. If you find it useful to add new test cases please do so within `tests/unit/test_util.py`. -```python -from tests import TestCase -import pybamm - - -class TestUtil(TestCase): - def test_optional_dependency(self): - # Test that an error is raised when pybtex is not available - with self.assertRaisesRegex( - ModuleNotFoundError, "Optional dependency pybtex is not available" - ): - sys.modules["pybtex"] = None - pybamm.function_using_pybtex(x, y, z) - - # Test that the function works when pybtex is available - sys.modules["pybtex"] = pybamm.util.import_optional_dependency("pybtex") - pybamm.function_using_pybtex(x, y, z) -``` +Currently, there are three functions to test what concerns optional dependencies: +- `test_import_optional_dependency` +- `test_pybamm_import` +- `test_optional_dependencies` + +The `test_import_optional_dependency` function extracts the optional dependencies installed in the setup environment, makes them unimportable (by setting them to `None` among the `sys.modules`), and tests that the `pybamm.util.import_optional_dependency` function throws a `ModuleNotFoundError` exception when their import is attempted. + +The `test_pybamm_import` function extracts the optional dependencies installed in the setup environment and makes them unimportable (by setting them to `None` among the `sys.modules`), unloads `pybamm` and its sub-modules, and finally tests that `pybamm` can be imported successfully. In fact, it is essential that the `pybamm` package is importable with only the mandatory dependencies. + +The `test_optional_dependencies` function extracts `pybamm` mandatory distribution packages and verifies that they are not present in the optional distribution packages list in `pyproject.toml`. This test is crucial for ensuring the consistency of the released package information and potential updates to dependencies during development. ## Testing diff --git a/pybamm/citations.py b/pybamm/citations.py index ff1851bfa..ae18f9adc 100644 --- a/pybamm/citations.py +++ b/pybamm/citations.py @@ -67,29 +67,41 @@ class Citations: """Reads the citations in `pybamm.CITATIONS.bib`. Other works can be cited by passing a BibTeX citation to :meth:`register`. """ - parse_file = import_optional_dependency("pybtex.database", "parse_file") - citations_file = os.path.join(pybamm.root_dir(), "pybamm", "CITATIONS.bib") - bib_data = parse_file(citations_file, bib_format="bibtex") - for key, entry in bib_data.entries.items(): - self._add_citation(key, entry) + try: + parse_file = import_optional_dependency("pybtex.database", "parse_file") + citations_file = os.path.join(pybamm.root_dir(), "pybamm", "CITATIONS.bib") + bib_data = parse_file(citations_file, bib_format="bibtex") + for key, entry in bib_data.entries.items(): + self._add_citation(key, entry) + except ModuleNotFoundError: # pragma: no cover + pybamm.logger.warning( + "Citations could not be read because the 'pybtex' library is not installed. " + "Install 'pybamm[cite]' to enable citation reading." + ) def _add_citation(self, key, entry): """Adds `entry` to `self._all_citations` under `key`, warning the user if a previous entry is overwritten """ - Entry = import_optional_dependency("pybtex.database", "Entry") - # Check input types are correct - if not isinstance(key, str) or not isinstance(entry, Entry): - raise TypeError() - - # Warn if overwriting a previous citation - new_citation = entry.to_string("bibtex") - if key in self._all_citations and new_citation != self._all_citations[key]: - warnings.warn(f"Replacing citation for {key}", stacklevel=2) - - # Add to database - self._all_citations[key] = new_citation + try: + Entry = import_optional_dependency("pybtex.database", "Entry") + # Check input types are correct + if not isinstance(key, str) or not isinstance(entry, Entry): + raise TypeError() + + # Warn if overwriting a previous citation + new_citation = entry.to_string("bibtex") + if key in self._all_citations and new_citation != self._all_citations[key]: + warnings.warn(f"Replacing citation for {key}", stacklevel=2) + + # Add to database + self._all_citations[key] = new_citation + except ModuleNotFoundError: # pragma: no cover + pybamm.logger.warning( + f"Could not add citation for '{key}' because the 'pybtex' library is not installed. " + "Install 'pybamm[cite]' to enable adding citations." + ) def _add_citation_tag(self, key, entry): """Adds a tag for a citation key in the dict, which represents the name of the @@ -143,24 +155,32 @@ class Citations: key: str A BibTeX formatted citation """ - PybtexError = import_optional_dependency("pybtex.scanner", "PybtexError") - parse_string = import_optional_dependency("pybtex.database", "parse_string") try: - # Parse string as a bibtex citation, and check that a citation was found - bib_data = parse_string(key, bib_format="bibtex") - if not bib_data.entries: - raise PybtexError("no entries found") - - # Add and register all citations - for key, entry in bib_data.entries.items(): - # Add to _all_citations dictionary - self._add_citation(key, entry) - # Add to _papers_to_cite set - self._papers_to_cite.add(key) - return - except PybtexError as error: - # Unable to parse / unknown key - raise KeyError(f"Not a bibtex citation or known citation: {key}") from error + PybtexError = import_optional_dependency("pybtex.scanner", "PybtexError") + parse_string = import_optional_dependency("pybtex.database", "parse_string") + try: + # Parse string as a bibtex citation, and check that a citation was found + bib_data = parse_string(key, bib_format="bibtex") + if not bib_data.entries: + raise PybtexError("no entries found") + + # Add and register all citations + for key, entry in bib_data.entries.items(): + # Add to _all_citations dictionary + self._add_citation(key, entry) + # Add to _papers_to_cite set + self._papers_to_cite.add(key) + return + except PybtexError as error: + # Unable to parse / unknown key + raise KeyError( + f"Not a bibtex citation or known citation: {key}" + ) from error + except ModuleNotFoundError: # pragma: no cover + pybamm.logger.warning( + f"Could not parse citation for '{key}' because the 'pybtex' library is not installed. " + "Install 'pybamm[cite]' to enable citation parsing." + ) def _tag_citations(self): """Prints the citation tags for the citations that have been registered @@ -211,38 +231,44 @@ class Citations: """ # Parse citations that were not known keys at registration, but do not # fail if they cannot be parsed - pybtex = import_optional_dependency("pybtex") try: - for key in self._unknown_citations: - self._parse_citation(key) - except KeyError: # pragma: no cover - warnings.warn( - message=f'\nCitation with key "{key}" is invalid. Please try again\n', - category=UserWarning, - stacklevel=2, - ) - # delete the invalid citation from the set - self._unknown_citations.remove(key) - - if output_format == "text": - citations = pybtex.format_from_strings( - self._cited, style="plain", output_backend="plaintext" + pybtex = import_optional_dependency("pybtex") + try: + for key in self._unknown_citations: + self._parse_citation(key) + except KeyError: # pragma: no cover + warnings.warn( + message=f'\nCitation with key "{key}" is invalid. Please try again\n', + category=UserWarning, + stacklevel=2, + ) + # delete the invalid citation from the set + self._unknown_citations.remove(key) + + if output_format == "text": + citations = pybtex.format_from_strings( + self._cited, style="plain", output_backend="plaintext" + ) + elif output_format == "bibtex": + citations = "\n".join(self._cited) + else: + raise pybamm.OptionError( + f"Output format {output_format} not recognised." + "It should be 'text' or 'bibtex'." + ) + + if filename is None: + print(citations) + if verbose: + self._tag_citations() # pragma: no cover + else: + with open(filename, "w") as f: + f.write(citations) + except ModuleNotFoundError: # pragma: no cover + pybamm.logger.warning( + "Could not print citations because the 'pybtex' library is not installed. " + "Please, install 'pybamm[cite]' to print citations." ) - elif output_format == "bibtex": - citations = "\n".join(self._cited) - else: - raise pybamm.OptionError( - f"Output format {output_format} not recognised." - "It should be 'text' or 'bibtex'." - ) - - if filename is None: - print(citations) - if verbose: - self._tag_citations() # pragma: no cover - else: - with open(filename, "w") as f: - f.write(citations) def print_citations(filename=None, output_format="text", verbose=False):
pybamm-team/PyBaMM
09ee982ba84055ec2c56f73b4cc63742c2ca0721
diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py index 3d6fafdd6..603af5056 100644 --- a/tests/unit/test_util.py +++ b/tests/unit/test_util.py @@ -93,7 +93,7 @@ class TestUtil(TestCase): "pybamm", optional_distribution_deps=optional_distribution_deps ) - # Save optional dependencies, then set to None + # Save optional dependencies, then make them not importable modules = {} for import_pkg in present_optional_import_deps: modules[import_pkg] = sys.modules.get(import_pkg) @@ -117,23 +117,31 @@ class TestUtil(TestCase): "pybamm", optional_distribution_deps=optional_distribution_deps ) - # Save optional dependencies, then set to None + # Save optional dependencies and their sub-modules, then make them not importable modules = {} - for import_pkg in present_optional_import_deps: - modules[import_pkg] = sys.modules.get(import_pkg) - sys.modules[import_pkg] = None + for module_name, module in sys.modules.items(): + base_module_name = module_name.split(".")[0] + if base_module_name in present_optional_import_deps: + modules[module_name] = module + sys.modules[module_name] = None + + # Unload pybamm and its sub-modules + for module_name in list(sys.modules.keys()): + base_module_name = module_name.split(".")[0] + if base_module_name == "pybamm": + sys.modules.pop(module_name) # Test pybamm is still importable try: - importlib.reload(importlib.import_module("pybamm")) + importlib.import_module("pybamm") except ModuleNotFoundError as error: self.fail( f"Import of 'pybamm' shouldn't require optional dependencies. Error: {error}" ) - - # Restore optional dependencies - for import_pkg in present_optional_import_deps: - sys.modules[import_pkg] = modules[import_pkg] + finally: + # Restore optional dependencies and their sub-modules + for module_name, module in modules.items(): + sys.modules[module_name] = module def test_optional_dependencies(self): optional_distribution_deps = get_optional_distribution_deps("pybamm")
PyBaMM import error - Cannot run anything (import broken due to `pybtex`) ### Discussed in https://github.com/pybamm-team/PyBaMM/discussions/3928 <div type='discussions-op-text'> <sup>Originally posted by **abhishek-appana** March 25, 2024</sup> Hello, I am running Python 3.11.8 and installed PyBaMM 24.1 using pip on a Windows system. Earlier I was using Python 3.10 and everything was fine. But I am getting the below error after upgrading Python. When I run `import pybamm`, it gives me the error: ModuleNotFoundError: Optional dependency pybtex.database is not available. See https://docs.pybamm.org/en/latest/source/user_guide/installation/index.html#optional-dependencies for more details. I tried installing pybamm using `pip install pybamm[all]`. I was still getting this error. How do I resolve this?</div> <hr> I think that this is a valid bug and it is still failing, and `import pybamm` should work without installing `pybamm[all]`. It can be noticed in the logs here: https://github.com/pybamm-team/PyBaMM/actions/runs/8461852686/job/23182296194, so I've converted this discussion to an issue instead (cc: @Saransh-cpp @arjxn-py). Perhaps this isn't being properly checked through #3892, @lorenzofavaro?
0.0
09ee982ba84055ec2c56f73b4cc63742c2ca0721
[ "tests/unit/test_util.py::TestUtil::test_is_jax_compatible", "tests/unit/test_util.py::TestSearch::test_url_gets_to_stdout", "tests/unit/test_util.py::TestUtil::test_get_parameters_filepath", "tests/unit/test_util.py::TestUtil::test_fuzzy_dict", "tests/unit/test_util.py::TestUtil::test_is_constant_and_can_evaluate", "tests/unit/test_util.py::TestUtil::test_git_commit_info", "tests/unit/test_util.py::TestUtil::test_optional_dependencies", "tests/unit/test_util.py::TestUtil::test_import_optional_dependency", "tests/unit/test_util.py::TestUtil::test_pybamm_import" ]
[]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2024-04-07 13:55:34+00:00
bsd-3-clause
4,706
pybel__pybel-384
diff --git a/src/pybel/parser/parse_concept.py b/src/pybel/parser/parse_concept.py index 0ea18dda..c8e94cad 100644 --- a/src/pybel/parser/parse_concept.py +++ b/src/pybel/parser/parse_concept.py @@ -13,7 +13,7 @@ from .exc import ( UndefinedNamespaceWarning, ) from .utils import quote, word -from ..constants import DIRTY, NAME, NAMESPACE +from ..constants import DIRTY, IDENTIFIER, NAME, NAMESPACE __all__ = [ 'ConceptParser', @@ -47,9 +47,18 @@ class ConceptParser(BaseParser): self.default_namespace = set(default_namespace) if default_namespace is not None else None self.allow_naked_names = allow_naked_names + self.identifier_fqualified = ( + word(NAMESPACE) + + Suppress(':') + + (word | quote)(IDENTIFIER) + + Suppress('!') + + (word | quote)(NAME) + ) + self.identifier_qualified = word(NAMESPACE) + Suppress(':') + (word | quote)(NAME) if self.namespace_to_terms: + self.identifier_fqualified.setParseAction(self.handle_identifier_qualified) self.identifier_qualified.setParseAction(self.handle_identifier_qualified) self.identifier_bare = (word | quote)(NAME) @@ -60,7 +69,9 @@ class ConceptParser(BaseParser): self.handle_namespace_invalid ) - super(ConceptParser, self).__init__(self.identifier_qualified | self.identifier_bare) + super().__init__( + self.identifier_fqualified | self.identifier_qualified | self.identifier_bare + ) def has_enumerated_namespace(self, namespace: str) -> bool: """Check that the namespace has been defined by an enumeration."""
pybel/pybel
11dd8c4d9008e3c0ea6c8b5fcb20e272215483b7
diff --git a/tests/test_parse/test_parse_bel.py b/tests/test_parse/test_parse_bel.py index 4a599f98..e76cc71d 100644 --- a/tests/test_parse/test_parse_bel.py +++ b/tests/test_parse/test_parse_bel.py @@ -9,7 +9,7 @@ from pybel import BELGraph from pybel.constants import ( ABUNDANCE, ACTIVITY, BEL_DEFAULT_NAMESPACE, BIOPROCESS, COMPLEX, COMPOSITE, CONCEPT, DEGRADATION, DIRECTLY_INCREASES, DIRTY, EFFECT, FRAGMENT, FROM_LOC, FUNCTION, FUSION, FUSION_MISSING, FUSION_REFERENCE, - FUSION_START, FUSION_STOP, GENE, HAS_COMPONENT, HAS_VARIANT, HGVS, KIND, LOCATION, MEMBERS, MIRNA, + FUSION_START, FUSION_STOP, GENE, HAS_COMPONENT, HAS_VARIANT, HGVS, IDENTIFIER, KIND, LOCATION, MEMBERS, MIRNA, MODIFIER, NAME, NAMESPACE, OBJECT, PARTNER_3P, PARTNER_5P, PATHOLOGY, PRODUCTS, PROTEIN, RANGE_3P, RANGE_5P, REACTANTS, REACTION, RELATION, RNA, SUBJECT, TARGET, TO_LOC, TRANSLOCATION, VARIANTS, ) @@ -89,6 +89,71 @@ class TestAbundance(TestTokenParserBase): self._test_abundance_with_location_helper('abundance(CHEBI:"oxygen atom", location(GO:intracellular))') +class TestAbundanceLabeled(TestTokenParserBase): + """2.1.1""" + + def setUp(self): + self.parser.clear() + self.parser.general_abundance.setParseAction(self.parser.handle_term) + + self.expected_node_data = abundance(namespace='chebi', name='oxygen atom', identifier='CHEBI:25805') + self.expected_canonical_bel = 'a(chebi:"oxygen atom")' + + def _test_abundance_helper(self, statement): + result = self.parser.general_abundance.parseString(statement) + self.assertEqual(dict(self.expected_node_data), result.asDict()) + + self.assertIn(self.expected_node_data, self.graph) + self.assertEqual(self.expected_canonical_bel, self.graph.node_to_bel(self.expected_node_data)) + + self.assertEqual({}, modifier_po_to_dict(result), msg='The modifier dictionary should be empty') + + def test_abundance(self): + """Test short/long abundance name.""" + self._test_abundance_helper('a(chebi:"CHEBI:25805"!"oxygen atom")') + self._test_abundance_helper('abundance(chebi:"CHEBI:25805"!"oxygen atom")') + self._test_abundance_helper('abundance(chebi:"CHEBI:25805" ! "oxygen atom")') + + def _test_abundance_with_location_helper(self, statement): + result = self.parser.general_abundance.parseString(statement) + + expected_result = { + FUNCTION: ABUNDANCE, + CONCEPT: { + NAMESPACE: 'chebi', + NAME: 'oxygen atom', + IDENTIFIER: 'CHEBI:25805', + }, + LOCATION: { + NAMESPACE: 'GO', + NAME: 'intracellular', + } + } + + self.assertEqual(expected_result, result.asDict()) + + self.assertIn(self.expected_node_data, self.graph) + self.assertEqual(self.expected_canonical_bel, self.graph.node_to_bel(self.expected_node_data)) + + modifier = modifier_po_to_dict(result) + expected_modifier = { + LOCATION: { + NAMESPACE: 'GO', + NAME: 'intracellular', + } + } + self.assertEqual(expected_modifier, modifier) + + def test_abundance_with_location(self): + """Test short/long abundance name and short/long location name.""" + self._test_abundance_with_location_helper('a(chebi:"CHEBI:25805"!"oxygen atom", loc(GO:intracellular))') + self._test_abundance_with_location_helper('abundance(chebi:"CHEBI:25805"!"oxygen atom", loc(GO:intracellular))') + self._test_abundance_with_location_helper('a(chebi:"CHEBI:25805"!"oxygen atom", location(GO:intracellular))') + self._test_abundance_with_location_helper( + 'abundance(chebi:"CHEBI:25805"!"oxygen atom", location(GO:intracellular))' + ) + + class TestGene(TestTokenParserBase): """2.1.4 http://openbel.org/language/web/version_2.0/bel_specification_version_2.0.html#XgeneA"""
Add OBO-style name/identifier parsing As a proof of concept, try parsing the identifier and name delimited by a `!` as in `p(HGNC:6893!MAPT)`. Quotes should be allowed on both the identifier and the name. Should whitespace should be allowed? `p(HGNC:6893 ! MAPT)`
0.0
11dd8c4d9008e3c0ea6c8b5fcb20e272215483b7
[ "tests/test_parse/test_parse_bel.py::TestAbundanceLabeled::test_abundance", "tests/test_parse/test_parse_bel.py::TestAbundanceLabeled::test_abundance_with_location" ]
[ "tests/test_parse/test_parse_bel.py::TestAbundance::test_abundance", "tests/test_parse/test_parse_bel.py::TestAbundance::test_abundance_with_location", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_fusion_1", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_fusion_2", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_fusion_3", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_fusion_legacy_1", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_fusion_legacy_2", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_simple", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_variant_chromosome", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_variant_deletion", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_variant_snp", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_with_gmod", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_with_hgvs", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_with_location", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_with_substitution", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_with_substitution_and_location", "tests/test_parse/test_parse_bel.py::TestGene::test_multiple_variants", "tests/test_parse/test_parse_bel.py::TestMicroRna::test_mirna_location", "tests/test_parse/test_parse_bel.py::TestMicroRna::test_mirna_variant", "tests/test_parse/test_parse_bel.py::TestMicroRna::test_mirna_variant_location", "tests/test_parse/test_parse_bel.py::TestMicroRna::test_short", "tests/test_parse/test_parse_bel.py::TestProtein::test_ensure_no_dup_edges", "tests/test_parse/test_parse_bel.py::TestProtein::test_multiple_variants", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fragment_descriptor", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fragment_known", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fragment_unboundTerminal", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fragment_unbounded", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fragment_unknown", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fusion_1", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fusion_legacy_1", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fusion_legacy_2", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_pmod_1", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_pmod_2", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_pmod_3", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_pmod_4", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_trunc_1", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_trunc_2", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_trunc_3", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_variant_deletion", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_variant_reference", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_variant_substitution", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_variant_unspecified", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_with_location", "tests/test_parse/test_parse_bel.py::TestProtein::test_reference", "tests/test_parse/test_parse_bel.py::TestRna::test_multiple_variants", "tests/test_parse/test_parse_bel.py::TestRna::test_reference", "tests/test_parse/test_parse_bel.py::TestRna::test_rna_fusion_known_breakpoints", "tests/test_parse/test_parse_bel.py::TestRna::test_rna_fusion_legacy_1", "tests/test_parse/test_parse_bel.py::TestRna::test_rna_fusion_unspecified_breakpoints", "tests/test_parse/test_parse_bel.py::TestRna::test_rna_variant_codingReference", "tests/test_parse/test_parse_bel.py::TestComplex::test_complex_list_long", "tests/test_parse/test_parse_bel.py::TestComplex::test_complex_list_short", "tests/test_parse/test_parse_bel.py::TestComplex::test_named_complex_singleton", "tests/test_parse/test_parse_bel.py::TestComposite::test_213a", "tests/test_parse/test_parse_bel.py::TestBiologicalProcess::test_231a", "tests/test_parse/test_parse_bel.py::TestPathology::test_232a", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_bare", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_legacy", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_on_listed_complex", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_on_named_complex", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_withMolecularActivityCustom", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_withMolecularActivityDefault", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_withMolecularActivityDefaultLong", "tests/test_parse/test_parse_bel.py::TestActivity::test_kinase_activity_on_listed_complex", "tests/test_parse/test_parse_bel.py::TestActivity::test_kinase_activity_on_named_complex", "tests/test_parse/test_parse_bel.py::TestTranslocationPermissive::test_unqualified_translocation_relation", "tests/test_parse/test_parse_bel.py::TestTranslocationPermissive::test_unqualified_translocation_single", "tests/test_parse/test_parse_bel.py::TestTransformation::test_clearance", "tests/test_parse/test_parse_bel.py::TestTransformation::test_degradation_long", "tests/test_parse/test_parse_bel.py::TestTransformation::test_degradation_short", "tests/test_parse/test_parse_bel.py::TestTransformation::test_reaction_1", "tests/test_parse/test_parse_bel.py::TestTransformation::test_reaction_2", "tests/test_parse/test_parse_bel.py::TestTransformation::test_translocation_bare", "tests/test_parse/test_parse_bel.py::TestTransformation::test_translocation_secretion", "tests/test_parse/test_parse_bel.py::TestTransformation::test_translocation_standard", "tests/test_parse/test_parse_bel.py::TestTransformation::test_translocation_surface", "tests/test_parse/test_parse_bel.py::TestTransformation::test_unqualified_translocation_strict", "tests/test_parse/test_parse_bel.py::TestSemantics::test_lenient_semantic_no_failure" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2019-07-16 19:13:36+00:00
mit
4,707
pybel__pybel-385
diff --git a/src/pybel/parser/parse_bel.py b/src/pybel/parser/parse_bel.py index 15af30bd..16f53149 100644 --- a/src/pybel/parser/parse_bel.py +++ b/src/pybel/parser/parse_bel.py @@ -262,6 +262,7 @@ class BELParser(BaseParser): :param required_annotations: Optional list of required annotations """ self.graph = graph + self.metagraph = set() self.allow_nested = allow_nested self.disallow_unqualified_translocations = disallow_unqualified_translocations @@ -637,17 +638,18 @@ class BELParser(BaseParser): if not self.allow_nested: raise NestedRelationWarning(self.get_line_number(), line, position) - self._handle_relation_harness(line, position, { + subject_hash = self._handle_relation_checked(line, position, { SUBJECT: tokens[SUBJECT], RELATION: tokens[RELATION], OBJECT: tokens[OBJECT][SUBJECT], }) - self._handle_relation_harness(line, position, { + object_hash = self._handle_relation_checked(line, position, { SUBJECT: tokens[OBJECT][SUBJECT], RELATION: tokens[OBJECT][RELATION], OBJECT: tokens[OBJECT][OBJECT], }) + self.metagraph.add((subject_hash, object_hash)) return tokens def check_function_semantics(self, line: str, position: int, tokens: ParseResults) -> ParseResults: @@ -784,6 +786,10 @@ class BELParser(BaseParser): Note: this can't be changed after instantiation! """ + self._handle_relation_checked(line, position, tokens) + return tokens + + def _handle_relation_checked(self, line, position, tokens): if not self.control_parser.citation: raise MissingCitationException(self.get_line_number(), line, position) @@ -794,8 +800,7 @@ class BELParser(BaseParser): if missing_required_annotations: raise MissingAnnotationWarning(self.get_line_number(), line, position, missing_required_annotations) - self._handle_relation(tokens) - return tokens + return self._handle_relation(tokens) def handle_unqualified_relation(self, _, __, tokens: ParseResults) -> ParseResults: """Handle unqualified relations."""
pybel/pybel
1975dec68f155d11173868474afd6860039e9775
diff --git a/tests/test_parse/test_parse_bel_relations.py b/tests/test_parse/test_parse_bel_relations.py index 3246177f..03b2102d 100644 --- a/tests/test_parse/test_parse_bel_relations.py +++ b/tests/test_parse/test_parse_bel_relations.py @@ -575,6 +575,7 @@ class TestRelations(TestTokenParserBase): self.assert_has_edge(cat, h2o2) self.assert_has_edge(h2o2, apoptosis) + self.assertEqual(1, len(self.parser.metagraph)) self.parser.lenient = False
Build metagraph from nested statements Though a graph data structure doesn't directly enable edges to be treated as nodes, edges can carry additional information about transitivity. For example, `A -> (B -> C)` is added to the graph as `A -> B` and `B -> C`, but both edges could include information about inwards transitivity and outwards transitivity. Each BELGraph could have an additional directed *metagraph* associated with it, where nodes are the hashes of edges in the original graph and edges denote the transitivity between them
0.0
1975dec68f155d11173868474afd6860039e9775
[ "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_nested_lenient" ]
[ "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_cnc_with_subject_variant", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_component_list", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_decreases", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_directlyDecreases", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_directlyDecreases_annotationExpansion", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_directlyIncreases_withTlocObject", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_ensure_no_dup_nodes", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_equivalentTo", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_extra_1", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_has_reaction_component", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_has_variant", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_increases", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_increases_methylation", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_is_a", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_label_1", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_member_list", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_negativeCorrelation_withObjectVariant", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_nested_failure", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_orthologous", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_partOf", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_positiveCorrelation_withSelfReferential", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_predicate_failure", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_rateLimitingStepOf_subjectActivity", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_regulates_with_multiple_nnotations", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_singleton", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_subProcessOf", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_transcription", "tests/test_parse/test_parse_bel_relations.py::TestRelations::test_translation", "tests/test_parse/test_parse_bel_relations.py::TestCustom::test_location_undefined_name", "tests/test_parse/test_parse_bel_relations.py::TestCustom::test_location_undefined_namespace", "tests/test_parse/test_parse_bel_relations.py::TestCustom::test_tloc_undefined_name", "tests/test_parse/test_parse_bel_relations.py::TestCustom::test_tloc_undefined_namespace" ]
{ "failed_lite_validators": [ "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2019-07-17 02:56:01+00:00
mit
4,708
pybel__pybel-404
diff --git a/src/pybel/constants.py b/src/pybel/constants.py index 7cc2e93a..08b381e6 100644 --- a/src/pybel/constants.py +++ b/src/pybel/constants.py @@ -205,6 +205,9 @@ BIOPROCESS = 'BiologicalProcess' #: Represents the BEL function, pathology() PATHOLOGY = 'Pathology' +#: Represents the BEL function, populationAbundance() +POPULATION = 'Population' + #: Represents the BEL abundance, compositeAbundance() COMPOSITE = 'Composite' @@ -226,6 +229,7 @@ PYBEL_NODE_FUNCTIONS = { COMPOSITE, COMPLEX, REACTION, + POPULATION, } #: The mapping from PyBEL node functions to BEL strings @@ -239,6 +243,7 @@ rev_abundance_labels = { PATHOLOGY: 'path', COMPLEX: 'complex', COMPOSITE: 'composite', + POPULATION: 'pop', } # Internal edge data keys diff --git a/src/pybel/dsl/__init__.py b/src/pybel/dsl/__init__.py index ccf03b32..e96f4add 100644 --- a/src/pybel/dsl/__init__.py +++ b/src/pybel/dsl/__init__.py @@ -10,7 +10,7 @@ from .node_classes import ( Abundance, BaseAbundance, BaseEntity, BiologicalProcess, CentralDogma, ComplexAbundance, CompositeAbundance, Entity, EnumeratedFusionRange, Fragment, FusionBase, FusionRangeBase, Gene, GeneFusion, GeneModification, Hgvs, HgvsReference, HgvsUnspecified, ListAbundance, MicroRna, MissingFusionRange, NamedComplexAbundance, Pathology, - Protein, ProteinFusion, ProteinModification, ProteinSubstitution, Reaction, Rna, RnaFusion, Variant, + Population, Protein, ProteinFusion, ProteinModification, ProteinSubstitution, Reaction, Rna, RnaFusion, Variant, ) entity = Entity diff --git a/src/pybel/dsl/constants.py b/src/pybel/dsl/constants.py index aa14194c..28d4c87d 100644 --- a/src/pybel/dsl/constants.py +++ b/src/pybel/dsl/constants.py @@ -4,10 +4,9 @@ from .node_classes import ( Abundance, BiologicalProcess, ComplexAbundance, CompositeAbundance, Gene, GeneFusion, MicroRna, - NamedComplexAbundance, - Pathology, Protein, ProteinFusion, Rna, RnaFusion, + NamedComplexAbundance, Pathology, Population, Protein, ProteinFusion, Rna, RnaFusion, ) -from ..constants import ABUNDANCE, BIOPROCESS, COMPLEX, COMPOSITE, GENE, MIRNA, PATHOLOGY, PROTEIN, RNA +from ..constants import ABUNDANCE, BIOPROCESS, COMPLEX, COMPOSITE, GENE, MIRNA, PATHOLOGY, POPULATION, PROTEIN, RNA __all__ = [ 'FUNC_TO_DSL', @@ -24,6 +23,7 @@ FUNC_TO_DSL = { BIOPROCESS: BiologicalProcess, COMPLEX: NamedComplexAbundance, ABUNDANCE: Abundance, + POPULATION: Population, } FUNC_TO_FUSION_DSL = { diff --git a/src/pybel/dsl/node_classes.py b/src/pybel/dsl/node_classes.py index dec3f612..cbffbcdd 100644 --- a/src/pybel/dsl/node_classes.py +++ b/src/pybel/dsl/node_classes.py @@ -12,7 +12,7 @@ from ..constants import ( ABUNDANCE, BEL_DEFAULT_NAMESPACE, BIOPROCESS, COMPLEX, COMPOSITE, CONCEPT, FRAGMENT, FRAGMENT_DESCRIPTION, FRAGMENT_MISSING, FRAGMENT_START, FRAGMENT_STOP, FUNCTION, FUSION, FUSION_MISSING, FUSION_REFERENCE, FUSION_START, FUSION_STOP, GENE, GMOD, HGVS, KIND, MEMBERS, MIRNA, PARTNER_3P, PARTNER_5P, PATHOLOGY, PMOD, PMOD_CODE, PMOD_ORDER, - PMOD_POSITION, PRODUCTS, PROTEIN, RANGE_3P, RANGE_5P, REACTANTS, REACTION, RNA, VARIANTS, XREFS, + PMOD_POSITION, POPULATION, PRODUCTS, PROTEIN, RANGE_3P, RANGE_5P, REACTANTS, REACTION, RNA, VARIANTS, XREFS, rev_abundance_labels, ) from ..language import Entity @@ -40,6 +40,7 @@ __all__ = [ 'CompositeAbundance', 'BiologicalProcess', 'Pathology', + 'Population', 'NamedComplexAbundance', 'Reaction', @@ -214,6 +215,17 @@ class Pathology(BaseAbundance): function = PATHOLOGY +class Population(BaseAbundance): + """Builds a popuation node. + + Example: + >>> Population(namespace='uberon', name='blood') + + """ + + function = POPULATION + + class Variant(dict, metaclass=ABCMeta): """The superclass for variant dictionaries.""" diff --git a/src/pybel/parser/parse_bel.py b/src/pybel/parser/parse_bel.py index 2ba93c9b..e42da96d 100644 --- a/src/pybel/parser/parse_bel.py +++ b/src/pybel/parser/parse_bel.py @@ -33,9 +33,9 @@ from ..constants import ( ABUNDANCE, ACTIVITY, ASSOCIATION, BEL_DEFAULT_NAMESPACE, BIOPROCESS, CAUSES_NO_CHANGE, CELL_SECRETION, CELL_SURFACE_EXPRESSION, COMPLEX, COMPOSITE, CONCEPT, DECREASES, DEGRADATION, DIRECTLY_DECREASES, DIRECTLY_INCREASES, DIRTY, EFFECT, EQUIVALENT_TO, FROM_LOC, FUNCTION, FUSION, GENE, INCREASES, IS_A, LINE, LOCATION, - MEMBERS, MIRNA, MODIFIER, NAME, NAMESPACE, NEGATIVE_CORRELATION, OBJECT, PART_OF, PATHOLOGY, POSITIVE_CORRELATION, - PRODUCTS, PROTEIN, REACTANTS, REACTION, REGULATES, RELATION, RNA, SUBJECT, TARGET, TO_LOC, TRANSCRIBED_TO, - TRANSLATED_TO, TRANSLOCATION, TWO_WAY_RELATIONS, VARIANTS, belns_encodings, + MEMBERS, MIRNA, MODIFIER, NAME, NAMESPACE, NEGATIVE_CORRELATION, OBJECT, PART_OF, PATHOLOGY, POPULATION, + POSITIVE_CORRELATION, PRODUCTS, PROTEIN, REACTANTS, REACTION, REGULATES, RELATION, RNA, SUBJECT, TARGET, TO_LOC, + TRANSCRIBED_TO, TRANSLATED_TO, TRANSLOCATION, TWO_WAY_RELATIONS, VARIANTS, belns_encodings, ) from ..dsl import BaseEntity, cell_surface_expression, secretion from ..tokens import parse_result_to_dsl @@ -110,6 +110,8 @@ biological_process_tag = one_of_tags(['bp', 'biologicalProcess'], BIOPROCESS, FU #: 2.3.2 http://openbel.org/language/version_2.0/bel_specification_version_2.0.html#_pathology_path pathology_tag = one_of_tags(['o', 'path', 'pathology'], PATHOLOGY, FUNCTION) +population_tag = one_of_tags(['pop', 'populationAbundance'], POPULATION, FUNCTION) + #: 2.3.3 http://openbel.org/language/version_2.0/bel_specification_version_2.0.html#Xactivity activity_tag = one_of_tags(['act', 'activity'], ACTIVITY, MODIFIER) @@ -422,7 +424,9 @@ class BELParser(BaseParser): #: `2.3.2 <http://openbel.org/language/version_2.0/bel_specification_version_2.0.html#_pathology_path>`_ self.pathology = pathology_tag + nest(concept) - self.bp_path = self.biological_process | self.pathology + self.population = population_tag + nest(concept) + + self.bp_path = self.biological_process | self.pathology | self.population self.bp_path.setParseAction(self.check_function_semantics) self.activity_standard = activity_tag + nest(
pybel/pybel
7d299ce6687ad37a6b0f9428cdc2990913c4b9a1
diff --git a/tests/test_parse/test_parse_bel.py b/tests/test_parse/test_parse_bel.py index 44442106..b6bfbd46 100644 --- a/tests/test_parse/test_parse_bel.py +++ b/tests/test_parse/test_parse_bel.py @@ -10,12 +10,12 @@ from pybel.constants import ( ABUNDANCE, ACTIVITY, BEL_DEFAULT_NAMESPACE, BIOPROCESS, COMPLEX, COMPOSITE, CONCEPT, DEGRADATION, DIRECTLY_INCREASES, DIRTY, EFFECT, FRAGMENT, FROM_LOC, FUNCTION, FUSION, FUSION_MISSING, FUSION_REFERENCE, FUSION_START, FUSION_STOP, GENE, HAS_VARIANT, HGVS, IDENTIFIER, KIND, LOCATION, MEMBERS, MIRNA, MODIFIER, NAME, - NAMESPACE, OBJECT, PARTNER_3P, PARTNER_5P, PART_OF, PATHOLOGY, PRODUCTS, PROTEIN, RANGE_3P, RANGE_5P, REACTANTS, - REACTION, RELATION, RNA, SUBJECT, TARGET, TO_LOC, TRANSLOCATION, VARIANTS, + NAMESPACE, OBJECT, PARTNER_3P, PARTNER_5P, PART_OF, PATHOLOGY, POPULATION, PRODUCTS, PROTEIN, RANGE_3P, RANGE_5P, + REACTANTS, REACTION, RELATION, RNA, SUBJECT, TARGET, TO_LOC, TRANSLOCATION, VARIANTS, ) from pybel.dsl import ( - Fragment, abundance, bioprocess, cell_surface_expression, complex_abundance, composite_abundance, fragment, - fusion_range, gene, gene_fusion, gmod, hgvs, mirna, named_complex_abundance, pathology, pmod, protein, + Fragment, Population, abundance, bioprocess, cell_surface_expression, complex_abundance, composite_abundance, + fragment, fusion_range, gene, gene_fusion, gmod, hgvs, mirna, named_complex_abundance, pathology, pmod, protein, protein_fusion, reaction, rna, rna_fusion, secretion, translocation, ) from pybel.dsl.namespaces import hgnc @@ -1499,6 +1499,32 @@ class TestPathology(TestTokenParserBase): self.assertEqual('path(MESH:adenocarcinoma)', self.graph.node_to_bel(expected_node)) +class TestPopulation(TestTokenParserBase): + def setUp(self): + self.parser.clear() + self.parser.population.setParseAction(self.parser.handle_term) + + def test_parse_population(self): + statement = 'pop(uberon:blood)' + result = self.parser.population.parseString(statement) + + expected_dict = { + FUNCTION: POPULATION, + CONCEPT: { + NAMESPACE: 'uberon', + NAME: 'blood', + }, + } + self.assertEqual(expected_dict, result.asDict()) + + expected_node = Population('uberon', 'blood') + self.assert_has_node(expected_node) + + self.assertEqual('pop(uberon:blood)', + self.graph.node_to_bel(expected_node), + msg='Nodes: {}'.format(list(self.graph))) + + class TestActivity(TestTokenParserBase): """Tests for molecular activity terms."""
Add BEP-0001 Support http://bep.bel.bio/published/BEP-0001.html
0.0
7d299ce6687ad37a6b0f9428cdc2990913c4b9a1
[ "tests/test_parse/test_parse_bel.py::TestAbundance::test_abundance", "tests/test_parse/test_parse_bel.py::TestAbundance::test_abundance_with_location", "tests/test_parse/test_parse_bel.py::TestAbundanceLabeled::test_abundance", "tests/test_parse/test_parse_bel.py::TestAbundanceLabeled::test_abundance_with_location", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_fusion_1", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_fusion_2", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_fusion_3", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_fusion_legacy_1", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_fusion_legacy_2", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_simple", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_variant_chromosome", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_variant_deletion", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_variant_snp", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_with_gmod", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_with_hgvs", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_with_location", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_with_substitution", "tests/test_parse/test_parse_bel.py::TestGene::test_gene_with_substitution_and_location", "tests/test_parse/test_parse_bel.py::TestGene::test_multiple_variants", "tests/test_parse/test_parse_bel.py::TestMicroRna::test_mirna_location", "tests/test_parse/test_parse_bel.py::TestMicroRna::test_mirna_variant", "tests/test_parse/test_parse_bel.py::TestMicroRna::test_mirna_variant_location", "tests/test_parse/test_parse_bel.py::TestMicroRna::test_short", "tests/test_parse/test_parse_bel.py::TestProtein::test_ensure_no_dup_edges", "tests/test_parse/test_parse_bel.py::TestProtein::test_multiple_variants", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fragment_descriptor", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fragment_known", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fragment_unboundTerminal", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fragment_unbounded", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fragment_unknown", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fusion_1", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fusion_legacy_1", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_fusion_legacy_2", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_pmod_1", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_pmod_2", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_pmod_3", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_pmod_4", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_trunc_1", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_trunc_2", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_trunc_3", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_variant_deletion", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_variant_reference", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_variant_substitution", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_variant_unspecified", "tests/test_parse/test_parse_bel.py::TestProtein::test_protein_with_location", "tests/test_parse/test_parse_bel.py::TestProtein::test_reference", "tests/test_parse/test_parse_bel.py::TestRna::test_multiple_variants", "tests/test_parse/test_parse_bel.py::TestRna::test_reference", "tests/test_parse/test_parse_bel.py::TestRna::test_rna_fusion_known_breakpoints", "tests/test_parse/test_parse_bel.py::TestRna::test_rna_fusion_legacy_1", "tests/test_parse/test_parse_bel.py::TestRna::test_rna_fusion_unspecified_breakpoints", "tests/test_parse/test_parse_bel.py::TestRna::test_rna_variant_codingReference", "tests/test_parse/test_parse_bel.py::TestComplex::test_complex_list_long", "tests/test_parse/test_parse_bel.py::TestComplex::test_complex_list_short", "tests/test_parse/test_parse_bel.py::TestComplex::test_named_complex_singleton", "tests/test_parse/test_parse_bel.py::TestComposite::test_213a", "tests/test_parse/test_parse_bel.py::TestBiologicalProcess::test_231a", "tests/test_parse/test_parse_bel.py::TestPathology::test_232a", "tests/test_parse/test_parse_bel.py::TestPopulation::test_parse_population", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_bare", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_legacy", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_on_listed_complex", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_on_named_complex", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_withMolecularActivityCustom", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_withMolecularActivityDefault", "tests/test_parse/test_parse_bel.py::TestActivity::test_activity_withMolecularActivityDefaultLong", "tests/test_parse/test_parse_bel.py::TestActivity::test_kinase_activity_on_listed_complex", "tests/test_parse/test_parse_bel.py::TestActivity::test_kinase_activity_on_named_complex", "tests/test_parse/test_parse_bel.py::TestTranslocationPermissive::test_unqualified_translocation_relation", "tests/test_parse/test_parse_bel.py::TestTranslocationPermissive::test_unqualified_translocation_single", "tests/test_parse/test_parse_bel.py::TestTransformation::test_clearance", "tests/test_parse/test_parse_bel.py::TestTransformation::test_degradation_long", "tests/test_parse/test_parse_bel.py::TestTransformation::test_degradation_short", "tests/test_parse/test_parse_bel.py::TestTransformation::test_reaction_1", "tests/test_parse/test_parse_bel.py::TestTransformation::test_reaction_2", "tests/test_parse/test_parse_bel.py::TestTransformation::test_translocation_bare", "tests/test_parse/test_parse_bel.py::TestTransformation::test_translocation_secretion", "tests/test_parse/test_parse_bel.py::TestTransformation::test_translocation_standard", "tests/test_parse/test_parse_bel.py::TestTransformation::test_translocation_surface", "tests/test_parse/test_parse_bel.py::TestTransformation::test_unqualified_translocation_strict", "tests/test_parse/test_parse_bel.py::TestSemantics::test_lenient_semantic_no_failure" ]
[]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2020-02-07 23:48:30+00:00
mit
4,709
pybel__pybel-460
diff --git a/src/pybel/parser/parse_concept.py b/src/pybel/parser/parse_concept.py index dc0d1cee..4ef7a15d 100644 --- a/src/pybel/parser/parse_concept.py +++ b/src/pybel/parser/parse_concept.py @@ -11,7 +11,7 @@ from pyparsing import ParseResults, Suppress from .baseparser import BaseParser from .constants import NamespaceTermEncodingMapping -from .utils import quote, word +from .utils import ns, quote from ..constants import DIRTY, IDENTIFIER, NAME, NAMESPACE from ..exceptions import ( MissingDefaultNameWarning, MissingNamespaceNameWarning, MissingNamespaceRegexWarning, NakedNameWarning, @@ -48,13 +48,13 @@ class ConceptParser(BaseParser): :param allow_naked_names: If true, turn off naked namespace failures """ self.identifier_fqualified = ( - word(NAMESPACE) + ns(NAMESPACE) + Suppress(':') - + (word | quote)(IDENTIFIER) + + (ns | quote)(IDENTIFIER) + Suppress('!') - + (word | quote)(NAME) + + (ns | quote)(NAME) ) - self.identifier_qualified = word(NAMESPACE) + Suppress(':') + (word | quote)(NAME) + self.identifier_qualified = ns(NAMESPACE) + Suppress(':') + (ns | quote)(NAME) if namespace_to_term_to_encoding is not None: self.namespace_to_name_to_encoding = defaultdict(dict) @@ -81,7 +81,7 @@ class ConceptParser(BaseParser): self.default_namespace = set(default_namespace) if default_namespace is not None else None self.allow_naked_names = allow_naked_names - self.identifier_bare = (word | quote)(NAME) + self.identifier_bare = (ns | quote)(NAME) self.identifier_bare.setParseAction( self.handle_namespace_default if self.default_namespace else self.handle_namespace_lenient if self.allow_naked_names else diff --git a/src/pybel/parser/parse_metadata.py b/src/pybel/parser/parse_metadata.py index d6588a50..686b4c81 100644 --- a/src/pybel/parser/parse_metadata.py +++ b/src/pybel/parser/parse_metadata.py @@ -6,11 +6,11 @@ import logging import re from typing import Mapping, Optional, Pattern, Set -from pyparsing import And, MatchFirst, ParseResults, Suppress, Word, pyparsing_common as ppc +from pyparsing import And, MatchFirst, ParseResults, Suppress, Word from .baseparser import BaseParser from .constants import NamespaceTermEncodingMapping -from .utils import delimited_quoted_list, qid, quote, word +from .utils import delimited_quoted_list, ns, qid, quote, word from ..constants import ( BEL_KEYWORD_ANNOTATION, BEL_KEYWORD_AS, BEL_KEYWORD_DEFINE, BEL_KEYWORD_DOCUMENT, BEL_KEYWORD_LIST, BEL_KEYWORD_NAMESPACE, BEL_KEYWORD_PATTERN, BEL_KEYWORD_SET, BEL_KEYWORD_URL, DOCUMENT_KEYS, METADATA_VERSION, @@ -117,11 +117,11 @@ class MetadataParser(BaseParser): qid('value'), ]) - namespace_tag = And([define_tag, Suppress(BEL_KEYWORD_NAMESPACE), ppc.identifier('name'), as_tag]) + namespace_tag = And([define_tag, Suppress(BEL_KEYWORD_NAMESPACE), ns('name'), as_tag]) self.namespace_url = And([namespace_tag, url_tag, quote('url')]) self.namespace_pattern = And([namespace_tag, Suppress(BEL_KEYWORD_PATTERN), quote('value')]) - annotation_tag = And([define_tag, Suppress(BEL_KEYWORD_ANNOTATION), ppc.identifier('name'), as_tag]) + annotation_tag = And([define_tag, Suppress(BEL_KEYWORD_ANNOTATION), ns('name'), as_tag]) self.annotation_url = And([annotation_tag, url_tag, quote('url')]) self.annotation_list = And([annotation_tag, list_tag, delimited_quoted_list('values')]) self.annotation_pattern = And([annotation_tag, Suppress(BEL_KEYWORD_PATTERN), quote('value')]) diff --git a/src/pybel/parser/utils.py b/src/pybel/parser/utils.py index 2f046420..b7bf7473 100644 --- a/src/pybel/parser/utils.py +++ b/src/pybel/parser/utils.py @@ -37,6 +37,7 @@ LP = Suppress('(') + W RP = W + Suppress(')') word = Word(alphanums) +ns = Word(alphanums + '_-.') identifier = Word(alphanums + '_') quote = dblQuotedString().setParseAction(removeQuotes) qid = quote | identifier
pybel/pybel
7503e179c9f0525414e86dc897ec746ee15ef65d
diff --git a/tests/test_parse/test_parse_identifier.py b/tests/test_parse/test_parse_identifier.py index cd180863..a5fc6e33 100644 --- a/tests/test_parse/test_parse_identifier.py +++ b/tests/test_parse/test_parse_identifier.py @@ -175,19 +175,25 @@ class TestConceptParserRegex(unittest.TestCase): """Tests for regular expression parsing""" def setUp(self) -> None: - self.parser = ConceptParser(namespace_to_pattern={'hgnc': re.compile(r'\d+')}) + self.parser = ConceptParser(namespace_to_pattern={ + 'hgnc': re.compile(r'\d+'), + 'ec-code': re.compile(r'.+'), + }) self.assertEqual({}, self.parser.namespace_to_identifier_to_encoding) self.assertEqual({}, self.parser.namespace_to_name_to_encoding) def test_valid(self): - s = 'hgnc:391' - result = self.parser.parseString(s) - - self.assertIn('namespace', result) - self.assertIn('name', result) - self.assertNotIn('identifier', result) - self.assertEqual('hgnc', result['namespace']) - self.assertEqual('391', result['name']) + for curie, namespace, name in [ + ('hgnc:391', 'hgnc', '391'), + ('ec-code:1.1.1.27', 'ec-code', '1.1.1.27'), + ]: + with self.subTest(curie=curie): + result = self.parser.parseString(curie) + self.assertIn('namespace', result) + self.assertIn('name', result) + self.assertNotIn('identifier', result) + self.assertEqual(namespace, result['namespace']) + self.assertEqual(name, result['name']) def test_invalid(self): """Test invalid BEL term.""" diff --git a/tests/test_parse/test_parse_metadata.py b/tests/test_parse/test_parse_metadata.py index af71c512..f1192e34 100644 --- a/tests/test_parse/test_parse_metadata.py +++ b/tests/test_parse/test_parse_metadata.py @@ -178,12 +178,15 @@ class TestParseMetadata(FleetingTemporaryCacheMixin): self.assertEqual(re.compile(r'\w+'), self.parser.annotation_to_pattern['Test']) def test_define_namespace_regex(self): - s = 'DEFINE NAMESPACE dbSNP AS PATTERN "rs[0-9]*"' - self.parser.parseString(s) - - self.assertNotIn('dbSNP', self.parser.namespace_to_term_to_encoding) - self.assertIn('dbSNP', self.parser.namespace_to_pattern) - self.assertEqual(re.compile('rs[0-9]*'), self.parser.namespace_to_pattern['dbSNP']) + for s, namespace, regex in [ + ('DEFINE NAMESPACE dbSNP AS PATTERN "rs[0-9]*"', 'dbSNP', re.compile(r'rs[0-9]*')), + ('DEFINE NAMESPACE ec-code AS PATTERN ".*"', 'ec-code', re.compile(r'.*')), + ]: + with self.subTest(namespace=namespace): + self.parser.parseString(s) + self.assertNotIn(namespace, self.parser.namespace_to_term_to_encoding) + self.assertIn(namespace, self.parser.namespace_to_pattern) + self.assertEqual(regex, self.parser.namespace_to_pattern[namespace]) def test_not_semantic_version(self): s = 'SET DOCUMENT Version = "1.0"'
Can't parse official ec-code keyword 1. dash in keyword is a problem 2. dots need to be quoted but they shouldn't have to be
0.0
7503e179c9f0525414e86dc897ec746ee15ef65d
[ "tests/test_parse/test_parse_identifier.py::TestConceptParserRegex::test_valid", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_define_namespace_regex" ]
[ "tests/test_parse/test_parse_identifier.py::TestConceptEnumerated::test_invalid_1", "tests/test_parse/test_parse_identifier.py::TestConceptEnumerated::test_invalid_2", "tests/test_parse/test_parse_identifier.py::TestConceptEnumerated::test_invalid_3", "tests/test_parse/test_parse_identifier.py::TestConceptEnumerated::test_invalid_4", "tests/test_parse/test_parse_identifier.py::TestConceptEnumerated::test_valid_1", "tests/test_parse/test_parse_identifier.py::TestConceptEnumerated::test_valid_2", "tests/test_parse/test_parse_identifier.py::TestConceptParserDefault::test_not_in_defaultNs", "tests/test_parse/test_parse_identifier.py::TestConceptParserDefault::test_valid_1", "tests/test_parse/test_parse_identifier.py::TestConceptParserDefault::test_valid_2", "tests/test_parse/test_parse_identifier.py::TestConceptParserDefault::test_valid_3", "tests/test_parse/test_parse_identifier.py::TestConceptParserLenient::test_invalid_1", "tests/test_parse/test_parse_identifier.py::TestConceptParserLenient::test_invalid_2", "tests/test_parse/test_parse_identifier.py::TestConceptParserLenient::test_not_invalid_3", "tests/test_parse/test_parse_identifier.py::TestConceptParserLenient::test_not_invalid_4", "tests/test_parse/test_parse_identifier.py::TestConceptParserLenient::test_valid_1", "tests/test_parse/test_parse_identifier.py::TestConceptParserLenient::test_valid_2", "tests/test_parse/test_parse_identifier.py::TestConceptParserRegex::test_invalid", "tests/test_parse/test_parse_identifier.py::TestConceptParserRegex::test_invalid_obo", "tests/test_parse/test_parse_identifier.py::TestConceptParserRegex::test_valid_obo", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_annotation_name_persistience_1", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_annotation_name_persistience_2", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_control_compound", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_document_metadata_exception", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_namespace_name_persistience", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_not_semantic_version", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_parse_annotation_pattern", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_parse_annotation_url_file", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_parse_document", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_parse_namespace_url_file", "tests/test_parse/test_parse_metadata.py::TestParseMetadata::test_underscore" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2020-07-29 11:13:53+00:00
mit
4,710
pybel__pybel-465
diff --git a/src/pybel/tokens.py b/src/pybel/tokens.py index 2a43df6b..9c34502d 100644 --- a/src/pybel/tokens.py +++ b/src/pybel/tokens.py @@ -2,7 +2,9 @@ """This module helps handle node data dictionaries.""" -from typing import List +from typing import Any, List, Mapping, Union + +from pyparsing import ParseResults from .constants import ( CONCEPT, FRAGMENT, FRAGMENT_DESCRIPTION, FRAGMENT_START, FRAGMENT_STOP, FUNCTION, FUSION, FUSION_MISSING, @@ -34,6 +36,8 @@ def parse_result_to_dsl(tokens) -> BaseEntity: return _variant_po_to_dict(tokens) elif MEMBERS in tokens: + if CONCEPT in tokens: + return _list_po_with_concept_to_dict(tokens) return _list_po_to_dict(tokens) elif FUSION in tokens: @@ -196,6 +200,25 @@ def _reaction_po_to_dict(tokens) -> Reaction: ) +def _list_po_with_concept_to_dict(tokens: Union[ParseResults, Mapping[str, Any]]) -> ListAbundance: + """Convert a list parse object to a node. + + :type tokens: ParseResult + """ + func = tokens[FUNCTION] + dsl = FUNC_TO_LIST_DSL[func] + members = _parse_tokens_list(tokens[MEMBERS]) + + concept = tokens[CONCEPT] + return dsl( + members=members, + namespace=concept[NAMESPACE], + name=concept.get(NAME), + identifier=concept.get(IDENTIFIER), + xrefs=tokens.get(XREFS), + ) + + def _list_po_to_dict(tokens) -> ListAbundance: """Convert a list parse object to a node.
pybel/pybel
81f400f64cdbe56f55a310fd37054a20703e3a94
diff --git a/tests/test_dsl.py b/tests/test_dsl.py index 76d8a9e9..bb177dd0 100644 --- a/tests/test_dsl.py +++ b/tests/test_dsl.py @@ -4,6 +4,7 @@ import unittest +import pybel.constants as pc from pybel import BELGraph from pybel.constants import NAME from pybel.dsl import ( @@ -12,6 +13,7 @@ from pybel.dsl import ( ) from pybel.language import Entity from pybel.testing.utils import n +from pybel.tokens import parse_result_to_dsl from pybel.utils import ensure_quotes @@ -210,5 +212,20 @@ class TestCentralDogma(unittest.TestCase): Reaction([], []) +class TestParse(unittest.TestCase): + """Test that :func:`parse_result_to_dsl` works correctly.""" + + def test_named_complex(self): + x = ComplexAbundance(namespace='a', identifier='b', members=[ + Protein(namespace='c', identifier='d'), + Protein(namespace='c', identifier='e'), + ]) + + y = parse_result_to_dsl(dict(x)) + self.assertIsInstance(y, ComplexAbundance) + self.assertIn(pc.MEMBERS, y) + self.assertIn(pc.CONCEPT, y) + + if __name__ == '__main__': unittest.main()
pybel.tokens.parse_result_to_dsl doesn't capture 'concept' information ### Current behavior When passing a pybel Entity to `parse_result_to_dsl()`, the 'concept' entries don't get mapped to a corresponding 'entity' parameter in the returned node. For example, when passing `{'function': 'Complex', 'members': [{}, {}], 'concept': {'namespace': 'hgnc', 'name': 'ca'}}` to the function, the BEL complex returned has an `entity` value of `None`, as shown in the following image. ![image](https://user-images.githubusercontent.com/45149156/90273727-69e91900-de2d-11ea-9b09-fbd28a0f55ac.png) ### Expected behavior Expected the function to return an `entity` value consistent with the node schema defined in the schema sub-module.
0.0
81f400f64cdbe56f55a310fd37054a20703e3a94
[ "tests/test_dsl.py::TestParse::test_named_complex" ]
[ "tests/test_dsl.py::TestDSL::test_GeneFusion", "tests/test_dsl.py::TestDSL::test_abundance_as_bel", "tests/test_dsl.py::TestDSL::test_abundance_as_bel_quoted", "tests/test_dsl.py::TestDSL::test_add_identified_node", "tests/test_dsl.py::TestDSL::test_add_named_node", "tests/test_dsl.py::TestDSL::test_add_robust_node", "tests/test_dsl.py::TestDSL::test_as_tuple", "tests/test_dsl.py::TestDSL::test_complex_with_name", "tests/test_dsl.py::TestDSL::test_empty_complex", "tests/test_dsl.py::TestDSL::test_empty_composite", "tests/test_dsl.py::TestDSL::test_gene_fusion_missing_explicit", "tests/test_dsl.py::TestDSL::test_gene_fusion_missing_implicit", "tests/test_dsl.py::TestDSL::test_missing_information", "tests/test_dsl.py::TestDSL::test_str_has_both", "tests/test_dsl.py::TestDSL::test_str_has_identifier", "tests/test_dsl.py::TestCentralDogma::test_get_parent", "tests/test_dsl.py::TestCentralDogma::test_list_abundance_has_contents", "tests/test_dsl.py::TestCentralDogma::test_reaction_has_contents", "tests/test_dsl.py::TestCentralDogma::test_with_variants", "tests/test_dsl.py::TestCentralDogma::test_with_variants_list" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_media" ], "has_test_patch": true, "is_lite": false }
2020-08-14 17:01:03+00:00
mit
4,711
pyca__bcrypt-86
diff --git a/.travis.yml b/.travis.yml index 456aba7..bbcb336 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,7 @@ matrix: env: TOXENV=pypy CC=clang - python: 2.7 env: TOXENV=pep8 + - env: TOXENV=packaging - python: 3.5 env: TOXENV=py3pep8 - language: generic diff --git a/MANIFEST.in b/MANIFEST.in index 622d66b..93a4480 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,11 @@ include LICENSE README.rst + +include tox.ini .coveragerc include src/build_bcrypt.py + recursive-include src/_csrc * +recursive-include tests *.py + +exclude requirements.txt tasks.py .travis.yml + +prune .travis diff --git a/README.rst b/README.rst index 0883286..3859bb8 100644 --- a/README.rst +++ b/README.rst @@ -40,6 +40,7 @@ Changelog 3.1.0 ----- * Added support for ``checkpw`` as another method of verifying a password. +* Ensure that you get a ``$2y$`` hash when you input a ``$2y$`` salt. 3.0.0 ----- @@ -104,7 +105,7 @@ the work factor merely pass the desired number of rounds to >>> hashed = bcrypt.hashpw(password, bcrypt.gensalt(14)) >>> # Check that a unhashed password matches one that has previously been >>> # hashed - >>> if bcrypt.hashpw(password, hashed) == hashed: + >>> if bcrypt.checkpw(password, hashed): ... print("It Matches!") ... else: ... print("It Does not Match :(") diff --git a/src/bcrypt/__init__.py b/src/bcrypt/__init__.py index d6acb84..abc9d75 100644 --- a/src/bcrypt/__init__.py +++ b/src/bcrypt/__init__.py @@ -39,10 +39,6 @@ __all__ = [ _normalize_re = re.compile(b"^\$2y\$") -def _normalize_prefix(salt): - return _normalize_re.sub(b"$2b$", salt) - - def gensalt(rounds=12, prefix=b"2b"): if prefix not in (b"2a", b"2b"): raise ValueError("Supported prefixes are b'2a' or b'2b'") @@ -75,7 +71,13 @@ def hashpw(password, salt): # on $2a$, so we do it here to preserve compatibility with 2.0.0 password = password[:72] - salt = _normalize_prefix(salt) + # When the original 8bit bug was found the original library we supported + # added a new prefix, $2y$, that fixes it. This prefix is exactly the same + # as the $2b$ prefix added by OpenBSD other than the name. Since the + # OpenBSD library does not support the $2y$ prefix, if the salt given to us + # is for the $2y$ prefix, we'll just mugne it so that it's a $2b$ prior to + # passing it into the C library. + original_salt, salt = salt, _normalize_re.sub(b"$2b$", salt) hashed = _bcrypt.ffi.new("unsigned char[]", 128) retval = _bcrypt.lib.bcrypt_hashpass(password, salt, hashed, len(hashed)) @@ -83,7 +85,13 @@ def hashpw(password, salt): if retval != 0: raise ValueError("Invalid salt") - return _bcrypt.ffi.string(hashed) + # Now that we've gotten our hashed password, we want to ensure that the + # prefix we return is the one that was passed in, so we'll use the prefix + # from the original salt and concatenate that with the return value (minus + # the return value's prefix). This will ensure that if someone passed in a + # salt with a $2y$ prefix, that they get back a hash with a $2y$ prefix + # even though we munged it to $2b$. + return original_salt[:4] + _bcrypt.ffi.string(hashed)[4:] def checkpw(password, hashed_password): @@ -96,9 +104,6 @@ def checkpw(password, hashed_password): "password and hashed_password may not contain NUL bytes" ) - # If the user supplies a $2y$ prefix we normalize to $2b$ - hashed_password = _normalize_prefix(hashed_password) - ret = hashpw(password, hashed_password) return _bcrypt.lib.timingsafe_bcmp(ret, hashed_password, len(ret)) == 0 diff --git a/tox.ini b/tox.ini index abc6283..264d9aa 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26,py27,pypy,py33,py34,py35,pep8,py3pep8 +envlist = py26,py27,pypy,py33,py34,py35,pep8,py3pep8,packaging [testenv] # If you add a new dep here you probably need to add it in setup.py as well @@ -27,6 +27,15 @@ deps = commands = flake8 . +[testenv:packaging] +deps = + check-manifest + readme_renderer +commands = + check-manifest + python setup.py check --metadata --restructuredtext --strict + + [flake8] exclude = .tox,*.egg select = E,W,F,N,I
pyca/bcrypt
c9c76210fad230995a6155287e8b92c49180eae4
diff --git a/tests/test_bcrypt.py b/tests/test_bcrypt.py index 47f315a..d9bde72 100644 --- a/tests/test_bcrypt.py +++ b/tests/test_bcrypt.py @@ -152,12 +152,12 @@ _2y_test_vectors = [ ( b"\xa3", b"$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq", - b"$2b$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq", + b"$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq", ), ( b"\xff\xff\xa3", b"$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e", - b"$2b$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e", + b"$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e", ), ]
Find a way to not use == in the README I don't think it's actually exploitable as a timing attack (in fact I'm pretty sure it's not), but I think it'd be good hygeine to offer a check_password function or similar and use that, so we dont' have to expose a general purpose constant time comparison function.
0.0
c9c76210fad230995a6155287e8b92c49180eae4
[ "tests/test_bcrypt.py::test_hashpw_2y_prefix[\\xa3-$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq-$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq]", "tests/test_bcrypt.py::test_hashpw_2y_prefix[\\xff\\xff\\xa3-$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e-$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e]" ]
[ "tests/test_bcrypt.py::test_gensalt_basic", "tests/test_bcrypt.py::test_gensalt_rounds_valid[4-$2b$04$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[5-$2b$05$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[6-$2b$06$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[7-$2b$07$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[8-$2b$08$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[9-$2b$09$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[10-$2b$10$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[11-$2b$11$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[12-$2b$12$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[13-$2b$13$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[14-$2b$14$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[15-$2b$15$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[16-$2b$16$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[17-$2b$17$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[18-$2b$18$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[19-$2b$19$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[20-$2b$20$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[21-$2b$21$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[22-$2b$22$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[23-$2b$23$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[24-$2b$24$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_invalid[1]", "tests/test_bcrypt.py::test_gensalt_rounds_invalid[2]", "tests/test_bcrypt.py::test_gensalt_rounds_invalid[3]", "tests/test_bcrypt.py::test_gensalt_bad_prefix", "tests/test_bcrypt.py::test_gensalt_2a_prefix", "tests/test_bcrypt.py::test_hashpw_new[Kk4DQuMMfZL9o-$2b$04$cVWp4XaNU8a4v1uMRum2SO-$2b$04$cVWp4XaNU8a4v1uMRum2SO026BWLIoQMD/TXg5uZV.0P.uO8m3YEm]", "tests/test_bcrypt.py::test_hashpw_new[9IeRXmnGxMYbs-$2b$04$pQ7gRO7e6wx/936oXhNjrO-$2b$04$pQ7gRO7e6wx/936oXhNjrOUNOHL1D0h1N2IDbJZYs.1ppzSof6SPy]", "tests/test_bcrypt.py::test_hashpw_new[xVQVbwa1S0M8r-$2b$04$SQe9knOzepOVKoYXo9xTte-$2b$04$SQe9knOzepOVKoYXo9xTteNYr6MBwVz4tpriJVe3PNgYufGIsgKcW]", "tests/test_bcrypt.py::test_hashpw_new[Zfgr26LWd22Za-$2b$04$eH8zX.q5Q.j2hO1NkVYJQO-$2b$04$eH8zX.q5Q.j2hO1NkVYJQOM6KxntS/ow3.YzVmFrE4t//CoF4fvne]", "tests/test_bcrypt.py::test_hashpw_new[Tg4daC27epFBE-$2b$04$ahiTdwRXpUG2JLRcIznxc.-$2b$04$ahiTdwRXpUG2JLRcIznxc.s1.ydaPGD372bsGs8NqyYjLY1inG5n2]", "tests/test_bcrypt.py::test_hashpw_new[xhQPMmwh5ALzW-$2b$04$nQn78dV0hGHf5wUBe0zOFu-$2b$04$nQn78dV0hGHf5wUBe0zOFu8n07ZbWWOKoGasZKRspZxtt.vBRNMIy]", "tests/test_bcrypt.py::test_hashpw_new[59je8h5Gj71tg-$2b$04$cvXudZ5ugTg95W.rOjMITu-$2b$04$cvXudZ5ugTg95W.rOjMITuM1jC0piCl3zF5cmGhzCibHZrNHkmckG]", "tests/test_bcrypt.py::test_hashpw_new[wT4fHJa2N9WSW-$2b$04$YYjtiq4Uh88yUsExO0RNTu-$2b$04$YYjtiq4Uh88yUsExO0RNTuEJ.tZlsONac16A8OcLHleWFjVawfGvO]", "tests/test_bcrypt.py::test_hashpw_new[uSgFRnQdOgm4S-$2b$04$WLTjgY/pZSyqX/fbMbJzf.-$2b$04$WLTjgY/pZSyqX/fbMbJzf.qxCeTMQOzgL.CimRjMHtMxd/VGKojMu]", "tests/test_bcrypt.py::test_hashpw_new[tEPtJZXur16Vg-$2b$04$2moPs/x/wnCfeQ5pCheMcu-$2b$04$2moPs/x/wnCfeQ5pCheMcuSJQ/KYjOZG780UjA/SiR.KsYWNrC7SG]", "tests/test_bcrypt.py::test_hashpw_new[vvho8C6nlVf9K-$2b$04$HrEYC/AQ2HS77G78cQDZQ.-$2b$04$HrEYC/AQ2HS77G78cQDZQ.r44WGcruKw03KHlnp71yVQEwpsi3xl2]", "tests/test_bcrypt.py::test_hashpw_new[5auCCY9by0Ruf-$2b$04$vVYgSTfB8KVbmhbZE/k3R.-$2b$04$vVYgSTfB8KVbmhbZE/k3R.ux9A0lJUM4CZwCkHI9fifke2.rTF7MG]", "tests/test_bcrypt.py::test_hashpw_new[GtTkR6qn2QOZW-$2b$04$JfoNrR8.doieoI8..F.C1O-$2b$04$JfoNrR8.doieoI8..F.C1OQgwE3uTeuardy6lw0AjALUzOARoyf2m]", "tests/test_bcrypt.py::test_hashpw_new[zKo8vdFSnjX0f-$2b$04$HP3I0PUs7KBEzMBNFw7o3O-$2b$04$HP3I0PUs7KBEzMBNFw7o3O7f/uxaZU7aaDot1quHMgB2yrwBXsgyy]", "tests/test_bcrypt.py::test_hashpw_new[I9VfYlacJiwiK-$2b$04$xnFVhJsTzsFBTeP3PpgbMe-$2b$04$xnFVhJsTzsFBTeP3PpgbMeMREb6rdKV9faW54Sx.yg9plf4jY8qT6]", "tests/test_bcrypt.py::test_hashpw_new[VFPO7YXnHQbQO-$2b$04$WQp9.igoLqVr6Qk70mz6xu-$2b$04$WQp9.igoLqVr6Qk70mz6xuRxE0RttVXXdukpR9N54x17ecad34ZF6]", "tests/test_bcrypt.py::test_hashpw_new[VDx5BdxfxstYk-$2b$04$xgZtlonpAHSU/njOCdKztO-$2b$04$xgZtlonpAHSU/njOCdKztOPuPFzCNVpB4LGicO4/OGgHv.uKHkwsS]", "tests/test_bcrypt.py::test_hashpw_new[dEe6XfVGrrfSH-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.GNj3aO0lb1E5E9UumYGKjP9BYqlNWJe]", "tests/test_bcrypt.py::test_hashpw_new[cTT0EAFdwJiLn-$2b$04$7/Qj7Kd8BcSahPO4khB8me-$2b$04$7/Qj7Kd8BcSahPO4khB8me4ssDJCW3r4OGYqPF87jxtrSyPj5cS5m]", "tests/test_bcrypt.py::test_hashpw_new[J8eHUDuxBB520-$2b$04$VvlCUKbTMjaxaYJ.k5juoe-$2b$04$VvlCUKbTMjaxaYJ.k5juoecpG/7IzcH1AkmqKi.lIZMVIOLClWAk.]", "tests/test_bcrypt.py::test_hashpw_new[U*U-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW]", "tests/test_bcrypt.py::test_hashpw_new[U*U*-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK]", "tests/test_bcrypt.py::test_hashpw_new[U*U*U-$2a$05$XXXXXXXXXXXXXXXXXXXXXO-$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a]", "tests/test_bcrypt.py::test_hashpw_new[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789chars", "tests/test_bcrypt.py::test_hashpw_new[\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaachars", "tests/test_bcrypt.py::test_hashpw_new[\\xa3-$2a$05$/OK.fbVrR/bpIqNJ5ianF.-$2a$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq]", "tests/test_bcrypt.py::test_checkpw[Kk4DQuMMfZL9o-$2b$04$cVWp4XaNU8a4v1uMRum2SO-$2b$04$cVWp4XaNU8a4v1uMRum2SO026BWLIoQMD/TXg5uZV.0P.uO8m3YEm]", "tests/test_bcrypt.py::test_checkpw[9IeRXmnGxMYbs-$2b$04$pQ7gRO7e6wx/936oXhNjrO-$2b$04$pQ7gRO7e6wx/936oXhNjrOUNOHL1D0h1N2IDbJZYs.1ppzSof6SPy]", "tests/test_bcrypt.py::test_checkpw[xVQVbwa1S0M8r-$2b$04$SQe9knOzepOVKoYXo9xTte-$2b$04$SQe9knOzepOVKoYXo9xTteNYr6MBwVz4tpriJVe3PNgYufGIsgKcW]", "tests/test_bcrypt.py::test_checkpw[Zfgr26LWd22Za-$2b$04$eH8zX.q5Q.j2hO1NkVYJQO-$2b$04$eH8zX.q5Q.j2hO1NkVYJQOM6KxntS/ow3.YzVmFrE4t//CoF4fvne]", "tests/test_bcrypt.py::test_checkpw[Tg4daC27epFBE-$2b$04$ahiTdwRXpUG2JLRcIznxc.-$2b$04$ahiTdwRXpUG2JLRcIznxc.s1.ydaPGD372bsGs8NqyYjLY1inG5n2]", "tests/test_bcrypt.py::test_checkpw[xhQPMmwh5ALzW-$2b$04$nQn78dV0hGHf5wUBe0zOFu-$2b$04$nQn78dV0hGHf5wUBe0zOFu8n07ZbWWOKoGasZKRspZxtt.vBRNMIy]", "tests/test_bcrypt.py::test_checkpw[59je8h5Gj71tg-$2b$04$cvXudZ5ugTg95W.rOjMITu-$2b$04$cvXudZ5ugTg95W.rOjMITuM1jC0piCl3zF5cmGhzCibHZrNHkmckG]", "tests/test_bcrypt.py::test_checkpw[wT4fHJa2N9WSW-$2b$04$YYjtiq4Uh88yUsExO0RNTu-$2b$04$YYjtiq4Uh88yUsExO0RNTuEJ.tZlsONac16A8OcLHleWFjVawfGvO]", "tests/test_bcrypt.py::test_checkpw[uSgFRnQdOgm4S-$2b$04$WLTjgY/pZSyqX/fbMbJzf.-$2b$04$WLTjgY/pZSyqX/fbMbJzf.qxCeTMQOzgL.CimRjMHtMxd/VGKojMu]", "tests/test_bcrypt.py::test_checkpw[tEPtJZXur16Vg-$2b$04$2moPs/x/wnCfeQ5pCheMcu-$2b$04$2moPs/x/wnCfeQ5pCheMcuSJQ/KYjOZG780UjA/SiR.KsYWNrC7SG]", "tests/test_bcrypt.py::test_checkpw[vvho8C6nlVf9K-$2b$04$HrEYC/AQ2HS77G78cQDZQ.-$2b$04$HrEYC/AQ2HS77G78cQDZQ.r44WGcruKw03KHlnp71yVQEwpsi3xl2]", "tests/test_bcrypt.py::test_checkpw[5auCCY9by0Ruf-$2b$04$vVYgSTfB8KVbmhbZE/k3R.-$2b$04$vVYgSTfB8KVbmhbZE/k3R.ux9A0lJUM4CZwCkHI9fifke2.rTF7MG]", "tests/test_bcrypt.py::test_checkpw[GtTkR6qn2QOZW-$2b$04$JfoNrR8.doieoI8..F.C1O-$2b$04$JfoNrR8.doieoI8..F.C1OQgwE3uTeuardy6lw0AjALUzOARoyf2m]", "tests/test_bcrypt.py::test_checkpw[zKo8vdFSnjX0f-$2b$04$HP3I0PUs7KBEzMBNFw7o3O-$2b$04$HP3I0PUs7KBEzMBNFw7o3O7f/uxaZU7aaDot1quHMgB2yrwBXsgyy]", "tests/test_bcrypt.py::test_checkpw[I9VfYlacJiwiK-$2b$04$xnFVhJsTzsFBTeP3PpgbMe-$2b$04$xnFVhJsTzsFBTeP3PpgbMeMREb6rdKV9faW54Sx.yg9plf4jY8qT6]", "tests/test_bcrypt.py::test_checkpw[VFPO7YXnHQbQO-$2b$04$WQp9.igoLqVr6Qk70mz6xu-$2b$04$WQp9.igoLqVr6Qk70mz6xuRxE0RttVXXdukpR9N54x17ecad34ZF6]", "tests/test_bcrypt.py::test_checkpw[VDx5BdxfxstYk-$2b$04$xgZtlonpAHSU/njOCdKztO-$2b$04$xgZtlonpAHSU/njOCdKztOPuPFzCNVpB4LGicO4/OGgHv.uKHkwsS]", "tests/test_bcrypt.py::test_checkpw[dEe6XfVGrrfSH-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.GNj3aO0lb1E5E9UumYGKjP9BYqlNWJe]", "tests/test_bcrypt.py::test_checkpw[cTT0EAFdwJiLn-$2b$04$7/Qj7Kd8BcSahPO4khB8me-$2b$04$7/Qj7Kd8BcSahPO4khB8me4ssDJCW3r4OGYqPF87jxtrSyPj5cS5m]", "tests/test_bcrypt.py::test_checkpw[J8eHUDuxBB520-$2b$04$VvlCUKbTMjaxaYJ.k5juoe-$2b$04$VvlCUKbTMjaxaYJ.k5juoecpG/7IzcH1AkmqKi.lIZMVIOLClWAk.]", "tests/test_bcrypt.py::test_checkpw[U*U-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW]", "tests/test_bcrypt.py::test_checkpw[U*U*-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK]", "tests/test_bcrypt.py::test_checkpw[U*U*U-$2a$05$XXXXXXXXXXXXXXXXXXXXXO-$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a]", "tests/test_bcrypt.py::test_checkpw[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789chars", "tests/test_bcrypt.py::test_checkpw[\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaachars", "tests/test_bcrypt.py::test_checkpw[\\xa3-$2a$05$/OK.fbVrR/bpIqNJ5ianF.-$2a$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq]", "tests/test_bcrypt.py::test_hashpw_existing[Kk4DQuMMfZL9o-$2b$04$cVWp4XaNU8a4v1uMRum2SO-$2b$04$cVWp4XaNU8a4v1uMRum2SO026BWLIoQMD/TXg5uZV.0P.uO8m3YEm]", "tests/test_bcrypt.py::test_hashpw_existing[9IeRXmnGxMYbs-$2b$04$pQ7gRO7e6wx/936oXhNjrO-$2b$04$pQ7gRO7e6wx/936oXhNjrOUNOHL1D0h1N2IDbJZYs.1ppzSof6SPy]", "tests/test_bcrypt.py::test_hashpw_existing[xVQVbwa1S0M8r-$2b$04$SQe9knOzepOVKoYXo9xTte-$2b$04$SQe9knOzepOVKoYXo9xTteNYr6MBwVz4tpriJVe3PNgYufGIsgKcW]", "tests/test_bcrypt.py::test_hashpw_existing[Zfgr26LWd22Za-$2b$04$eH8zX.q5Q.j2hO1NkVYJQO-$2b$04$eH8zX.q5Q.j2hO1NkVYJQOM6KxntS/ow3.YzVmFrE4t//CoF4fvne]", "tests/test_bcrypt.py::test_hashpw_existing[Tg4daC27epFBE-$2b$04$ahiTdwRXpUG2JLRcIznxc.-$2b$04$ahiTdwRXpUG2JLRcIznxc.s1.ydaPGD372bsGs8NqyYjLY1inG5n2]", "tests/test_bcrypt.py::test_hashpw_existing[xhQPMmwh5ALzW-$2b$04$nQn78dV0hGHf5wUBe0zOFu-$2b$04$nQn78dV0hGHf5wUBe0zOFu8n07ZbWWOKoGasZKRspZxtt.vBRNMIy]", "tests/test_bcrypt.py::test_hashpw_existing[59je8h5Gj71tg-$2b$04$cvXudZ5ugTg95W.rOjMITu-$2b$04$cvXudZ5ugTg95W.rOjMITuM1jC0piCl3zF5cmGhzCibHZrNHkmckG]", "tests/test_bcrypt.py::test_hashpw_existing[wT4fHJa2N9WSW-$2b$04$YYjtiq4Uh88yUsExO0RNTu-$2b$04$YYjtiq4Uh88yUsExO0RNTuEJ.tZlsONac16A8OcLHleWFjVawfGvO]", "tests/test_bcrypt.py::test_hashpw_existing[uSgFRnQdOgm4S-$2b$04$WLTjgY/pZSyqX/fbMbJzf.-$2b$04$WLTjgY/pZSyqX/fbMbJzf.qxCeTMQOzgL.CimRjMHtMxd/VGKojMu]", "tests/test_bcrypt.py::test_hashpw_existing[tEPtJZXur16Vg-$2b$04$2moPs/x/wnCfeQ5pCheMcu-$2b$04$2moPs/x/wnCfeQ5pCheMcuSJQ/KYjOZG780UjA/SiR.KsYWNrC7SG]", "tests/test_bcrypt.py::test_hashpw_existing[vvho8C6nlVf9K-$2b$04$HrEYC/AQ2HS77G78cQDZQ.-$2b$04$HrEYC/AQ2HS77G78cQDZQ.r44WGcruKw03KHlnp71yVQEwpsi3xl2]", "tests/test_bcrypt.py::test_hashpw_existing[5auCCY9by0Ruf-$2b$04$vVYgSTfB8KVbmhbZE/k3R.-$2b$04$vVYgSTfB8KVbmhbZE/k3R.ux9A0lJUM4CZwCkHI9fifke2.rTF7MG]", "tests/test_bcrypt.py::test_hashpw_existing[GtTkR6qn2QOZW-$2b$04$JfoNrR8.doieoI8..F.C1O-$2b$04$JfoNrR8.doieoI8..F.C1OQgwE3uTeuardy6lw0AjALUzOARoyf2m]", "tests/test_bcrypt.py::test_hashpw_existing[zKo8vdFSnjX0f-$2b$04$HP3I0PUs7KBEzMBNFw7o3O-$2b$04$HP3I0PUs7KBEzMBNFw7o3O7f/uxaZU7aaDot1quHMgB2yrwBXsgyy]", "tests/test_bcrypt.py::test_hashpw_existing[I9VfYlacJiwiK-$2b$04$xnFVhJsTzsFBTeP3PpgbMe-$2b$04$xnFVhJsTzsFBTeP3PpgbMeMREb6rdKV9faW54Sx.yg9plf4jY8qT6]", "tests/test_bcrypt.py::test_hashpw_existing[VFPO7YXnHQbQO-$2b$04$WQp9.igoLqVr6Qk70mz6xu-$2b$04$WQp9.igoLqVr6Qk70mz6xuRxE0RttVXXdukpR9N54x17ecad34ZF6]", "tests/test_bcrypt.py::test_hashpw_existing[VDx5BdxfxstYk-$2b$04$xgZtlonpAHSU/njOCdKztO-$2b$04$xgZtlonpAHSU/njOCdKztOPuPFzCNVpB4LGicO4/OGgHv.uKHkwsS]", "tests/test_bcrypt.py::test_hashpw_existing[dEe6XfVGrrfSH-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.GNj3aO0lb1E5E9UumYGKjP9BYqlNWJe]", "tests/test_bcrypt.py::test_hashpw_existing[cTT0EAFdwJiLn-$2b$04$7/Qj7Kd8BcSahPO4khB8me-$2b$04$7/Qj7Kd8BcSahPO4khB8me4ssDJCW3r4OGYqPF87jxtrSyPj5cS5m]", "tests/test_bcrypt.py::test_hashpw_existing[J8eHUDuxBB520-$2b$04$VvlCUKbTMjaxaYJ.k5juoe-$2b$04$VvlCUKbTMjaxaYJ.k5juoecpG/7IzcH1AkmqKi.lIZMVIOLClWAk.]", "tests/test_bcrypt.py::test_hashpw_existing[U*U-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW]", "tests/test_bcrypt.py::test_hashpw_existing[U*U*-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK]", "tests/test_bcrypt.py::test_hashpw_existing[U*U*U-$2a$05$XXXXXXXXXXXXXXXXXXXXXO-$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a]", "tests/test_bcrypt.py::test_hashpw_existing[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789chars", "tests/test_bcrypt.py::test_hashpw_existing[\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaachars", "tests/test_bcrypt.py::test_hashpw_existing[\\xa3-$2a$05$/OK.fbVrR/bpIqNJ5ianF.-$2a$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq]", "tests/test_bcrypt.py::test_checkpw_2y_prefix[\\xa3-$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq-$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq]", "tests/test_bcrypt.py::test_checkpw_2y_prefix[\\xff\\xff\\xa3-$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e-$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e]", "tests/test_bcrypt.py::test_hashpw_invalid", "tests/test_bcrypt.py::test_checkpw_wrong_password", "tests/test_bcrypt.py::test_checkpw_bad_salt", "tests/test_bcrypt.py::test_checkpw_str_password", "tests/test_bcrypt.py::test_checkpw_str_salt", "tests/test_bcrypt.py::test_hashpw_str_password", "tests/test_bcrypt.py::test_hashpw_str_salt", "tests/test_bcrypt.py::test_checkpw_nul_byte", "tests/test_bcrypt.py::test_hashpw_nul_byte", "tests/test_bcrypt.py::test_kdf[4-password-salt-[\\xbf\\x0c\\xc2\\x93X\\x7f\\x1c65U\\'ye\\x98\\xd4~W\\x90q\\xbfB~\\x9d\\x8f\\xbe\\x84*\\xba4\\xd9]", "tests/test_bcrypt.py::test_kdf[4-password-\\x00-\\xc1+Vb5\\xee\\xe0L!%\\x98\\x97\\nW\\x9ag]", "tests/test_bcrypt.py::test_kdf[4-\\x00-salt-`Q\\xbe\\x18\\xc2\\xf4\\xf8,\\xbf\\x0e\\xfe\\xe5G\\x1bK\\xb9]", "tests/test_bcrypt.py::test_kdf[4-password\\x00-salt\\x00-t\\x10\\xe4L\\xf4\\xfa\\x07\\xbf\\xaa\\xc8\\xa9(\\xb1r\\x7f\\xac\\x00\\x13u\\xe7\\xbfs\\x847\\x0fH\\xef\\xd1!t0P]", "tests/test_bcrypt.py::test_kdf[4-pass\\x00wor-sa\\x00l-\\xc2\\xbf\\xfd\\x9d\\xb3\\x8fei\\xef\\xefCr\\xf4\\xde\\x83\\xc0]", "tests/test_bcrypt.py::test_kdf[4-pass\\x00word-sa\\x00lt-K\\xa4\\xac9%\\xc0\\xe8\\xd7\\xf0\\xcd\\xb6\\xbb\\x16\\x84\\xa5o]", "tests/test_bcrypt.py::test_kdf[8-password-salt-\\xe16~\\xc5\\x15\\x1a3\\xfa\\xacL\\xc1\\xc1D\\xcd#\\xfa\\x15\\xd5T\\x84\\x93\\xec\\xc9\\x9b\\x9b]\\x9c\\r;'\\xbe\\xc7b'\\xeaf\\x08\\x8b\\x84\\x9b", "tests/test_bcrypt.py::test_kdf[42-password-salt-\\x83<\\xf0\\xdc\\xf5m\\xb6V\\x08\\xe8\\xf0\\xdc\\x0c\\xe8\\x82\\xbd]", "tests/test_bcrypt.py::test_kdf[8-Lorem", "tests/test_bcrypt.py::test_kdf[8-\\r\\xb3\\xac\\x94\\xb3\\xeeS(OJ\"\\x89;<$\\xae-:b\\xf0\\xf0\\xdb\\xce\\xf8#\\xcf\\xcc\\x85HV\\xea\\x10(-", "tests/test_bcrypt.py::test_kdf[8-\\xe1\\xbd\\x88\\xce\\xb4\\xcf\\x85\\xcf\\x83\\xcf\\x83\\xce\\xb5\\xcf\\x8d\\xcf\\x82-\\xce\\xa4\\xce\\xb7\\xce\\xbb\\xce\\xad\\xce\\xbc\\xce\\xb1\\xcf\\x87\\xce\\xbf\\xcf\\x82-Cfl\\x9b\\t\\xef3\\xed\\x8c'\\xe8\\xe8\\xf3\\xe2\\xd8\\xe6]", "tests/test_bcrypt.py::test_kdf_str_password", "tests/test_bcrypt.py::test_kdf_str_salt", "tests/test_bcrypt.py::test_invalid_params[pass-$2b$04$cVWp4XaNU8a4v1uMRum2SO-10-10-TypeError]", "tests/test_bcrypt.py::test_invalid_params[password-salt-10-10-TypeError]", "tests/test_bcrypt.py::test_invalid_params[-$2b$04$cVWp4XaNU8a4v1uMRum2SO-10-10-ValueError]", "tests/test_bcrypt.py::test_invalid_params[password--10-10-ValueError]", "tests/test_bcrypt.py::test_invalid_params[password-$2b$04$cVWp4XaNU8a4v1uMRum2SO-0-10-ValueError]", "tests/test_bcrypt.py::test_invalid_params[password-$2b$04$cVWp4XaNU8a4v1uMRum2SO--3-10-ValueError]", "tests/test_bcrypt.py::test_invalid_params[password-$2b$04$cVWp4XaNU8a4v1uMRum2SO-513-10-ValueError]", "tests/test_bcrypt.py::test_invalid_params[password-$2b$04$cVWp4XaNU8a4v1uMRum2SO-20-0-ValueError]", "tests/test_bcrypt.py::test_bcrypt_assert", "tests/test_bcrypt.py::test_2a_wraparound_bug" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2016-06-30 16:21:32+00:00
apache-2.0
4,712
pyca__bcrypt-87
diff --git a/.travis.yml b/.travis.yml index 456aba7..bbcb336 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,7 @@ matrix: env: TOXENV=pypy CC=clang - python: 2.7 env: TOXENV=pep8 + - env: TOXENV=packaging - python: 3.5 env: TOXENV=py3pep8 - language: generic diff --git a/MANIFEST.in b/MANIFEST.in index 622d66b..93a4480 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,11 @@ include LICENSE README.rst + +include tox.ini .coveragerc include src/build_bcrypt.py + recursive-include src/_csrc * +recursive-include tests *.py + +exclude requirements.txt tasks.py .travis.yml + +prune .travis diff --git a/README.rst b/README.rst index 0883286..b8c75a9 100644 --- a/README.rst +++ b/README.rst @@ -40,6 +40,7 @@ Changelog 3.1.0 ----- * Added support for ``checkpw`` as another method of verifying a password. +* Ensure that you get a ``$2y$`` hash when you input a ``$2y$`` salt. 3.0.0 ----- diff --git a/src/bcrypt/__init__.py b/src/bcrypt/__init__.py index d6acb84..abc9d75 100644 --- a/src/bcrypt/__init__.py +++ b/src/bcrypt/__init__.py @@ -39,10 +39,6 @@ __all__ = [ _normalize_re = re.compile(b"^\$2y\$") -def _normalize_prefix(salt): - return _normalize_re.sub(b"$2b$", salt) - - def gensalt(rounds=12, prefix=b"2b"): if prefix not in (b"2a", b"2b"): raise ValueError("Supported prefixes are b'2a' or b'2b'") @@ -75,7 +71,13 @@ def hashpw(password, salt): # on $2a$, so we do it here to preserve compatibility with 2.0.0 password = password[:72] - salt = _normalize_prefix(salt) + # When the original 8bit bug was found the original library we supported + # added a new prefix, $2y$, that fixes it. This prefix is exactly the same + # as the $2b$ prefix added by OpenBSD other than the name. Since the + # OpenBSD library does not support the $2y$ prefix, if the salt given to us + # is for the $2y$ prefix, we'll just mugne it so that it's a $2b$ prior to + # passing it into the C library. + original_salt, salt = salt, _normalize_re.sub(b"$2b$", salt) hashed = _bcrypt.ffi.new("unsigned char[]", 128) retval = _bcrypt.lib.bcrypt_hashpass(password, salt, hashed, len(hashed)) @@ -83,7 +85,13 @@ def hashpw(password, salt): if retval != 0: raise ValueError("Invalid salt") - return _bcrypt.ffi.string(hashed) + # Now that we've gotten our hashed password, we want to ensure that the + # prefix we return is the one that was passed in, so we'll use the prefix + # from the original salt and concatenate that with the return value (minus + # the return value's prefix). This will ensure that if someone passed in a + # salt with a $2y$ prefix, that they get back a hash with a $2y$ prefix + # even though we munged it to $2b$. + return original_salt[:4] + _bcrypt.ffi.string(hashed)[4:] def checkpw(password, hashed_password): @@ -96,9 +104,6 @@ def checkpw(password, hashed_password): "password and hashed_password may not contain NUL bytes" ) - # If the user supplies a $2y$ prefix we normalize to $2b$ - hashed_password = _normalize_prefix(hashed_password) - ret = hashpw(password, hashed_password) return _bcrypt.lib.timingsafe_bcmp(ret, hashed_password, len(ret)) == 0 diff --git a/tox.ini b/tox.ini index abc6283..264d9aa 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26,py27,pypy,py33,py34,py35,pep8,py3pep8 +envlist = py26,py27,pypy,py33,py34,py35,pep8,py3pep8,packaging [testenv] # If you add a new dep here you probably need to add it in setup.py as well @@ -27,6 +27,15 @@ deps = commands = flake8 . +[testenv:packaging] +deps = + check-manifest + readme_renderer +commands = + check-manifest + python setup.py check --metadata --restructuredtext --strict + + [flake8] exclude = .tox,*.egg select = E,W,F,N,I
pyca/bcrypt
c9c76210fad230995a6155287e8b92c49180eae4
diff --git a/tests/test_bcrypt.py b/tests/test_bcrypt.py index 47f315a..d9bde72 100644 --- a/tests/test_bcrypt.py +++ b/tests/test_bcrypt.py @@ -152,12 +152,12 @@ _2y_test_vectors = [ ( b"\xa3", b"$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq", - b"$2b$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq", + b"$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq", ), ( b"\xff\xff\xa3", b"$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e", - b"$2b$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e", + b"$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e", ), ]
testsuite absent The setup.py is filled with references to the testsuite and designates pytest as a test runner, despite the tests folder being absent from the tarball.
0.0
c9c76210fad230995a6155287e8b92c49180eae4
[ "tests/test_bcrypt.py::test_hashpw_2y_prefix[\\xa3-$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq-$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq]", "tests/test_bcrypt.py::test_hashpw_2y_prefix[\\xff\\xff\\xa3-$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e-$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e]" ]
[ "tests/test_bcrypt.py::test_gensalt_basic", "tests/test_bcrypt.py::test_gensalt_rounds_valid[4-$2b$04$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[5-$2b$05$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[6-$2b$06$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[7-$2b$07$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[8-$2b$08$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[9-$2b$09$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[10-$2b$10$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[11-$2b$11$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[12-$2b$12$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[13-$2b$13$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[14-$2b$14$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[15-$2b$15$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[16-$2b$16$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[17-$2b$17$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[18-$2b$18$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[19-$2b$19$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[20-$2b$20$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[21-$2b$21$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[22-$2b$22$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[23-$2b$23$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_valid[24-$2b$24$KB.uKB.uKB.uKB.uKB.uK.]", "tests/test_bcrypt.py::test_gensalt_rounds_invalid[1]", "tests/test_bcrypt.py::test_gensalt_rounds_invalid[2]", "tests/test_bcrypt.py::test_gensalt_rounds_invalid[3]", "tests/test_bcrypt.py::test_gensalt_bad_prefix", "tests/test_bcrypt.py::test_gensalt_2a_prefix", "tests/test_bcrypt.py::test_hashpw_new[Kk4DQuMMfZL9o-$2b$04$cVWp4XaNU8a4v1uMRum2SO-$2b$04$cVWp4XaNU8a4v1uMRum2SO026BWLIoQMD/TXg5uZV.0P.uO8m3YEm]", "tests/test_bcrypt.py::test_hashpw_new[9IeRXmnGxMYbs-$2b$04$pQ7gRO7e6wx/936oXhNjrO-$2b$04$pQ7gRO7e6wx/936oXhNjrOUNOHL1D0h1N2IDbJZYs.1ppzSof6SPy]", "tests/test_bcrypt.py::test_hashpw_new[xVQVbwa1S0M8r-$2b$04$SQe9knOzepOVKoYXo9xTte-$2b$04$SQe9knOzepOVKoYXo9xTteNYr6MBwVz4tpriJVe3PNgYufGIsgKcW]", "tests/test_bcrypt.py::test_hashpw_new[Zfgr26LWd22Za-$2b$04$eH8zX.q5Q.j2hO1NkVYJQO-$2b$04$eH8zX.q5Q.j2hO1NkVYJQOM6KxntS/ow3.YzVmFrE4t//CoF4fvne]", "tests/test_bcrypt.py::test_hashpw_new[Tg4daC27epFBE-$2b$04$ahiTdwRXpUG2JLRcIznxc.-$2b$04$ahiTdwRXpUG2JLRcIznxc.s1.ydaPGD372bsGs8NqyYjLY1inG5n2]", "tests/test_bcrypt.py::test_hashpw_new[xhQPMmwh5ALzW-$2b$04$nQn78dV0hGHf5wUBe0zOFu-$2b$04$nQn78dV0hGHf5wUBe0zOFu8n07ZbWWOKoGasZKRspZxtt.vBRNMIy]", "tests/test_bcrypt.py::test_hashpw_new[59je8h5Gj71tg-$2b$04$cvXudZ5ugTg95W.rOjMITu-$2b$04$cvXudZ5ugTg95W.rOjMITuM1jC0piCl3zF5cmGhzCibHZrNHkmckG]", "tests/test_bcrypt.py::test_hashpw_new[wT4fHJa2N9WSW-$2b$04$YYjtiq4Uh88yUsExO0RNTu-$2b$04$YYjtiq4Uh88yUsExO0RNTuEJ.tZlsONac16A8OcLHleWFjVawfGvO]", "tests/test_bcrypt.py::test_hashpw_new[uSgFRnQdOgm4S-$2b$04$WLTjgY/pZSyqX/fbMbJzf.-$2b$04$WLTjgY/pZSyqX/fbMbJzf.qxCeTMQOzgL.CimRjMHtMxd/VGKojMu]", "tests/test_bcrypt.py::test_hashpw_new[tEPtJZXur16Vg-$2b$04$2moPs/x/wnCfeQ5pCheMcu-$2b$04$2moPs/x/wnCfeQ5pCheMcuSJQ/KYjOZG780UjA/SiR.KsYWNrC7SG]", "tests/test_bcrypt.py::test_hashpw_new[vvho8C6nlVf9K-$2b$04$HrEYC/AQ2HS77G78cQDZQ.-$2b$04$HrEYC/AQ2HS77G78cQDZQ.r44WGcruKw03KHlnp71yVQEwpsi3xl2]", "tests/test_bcrypt.py::test_hashpw_new[5auCCY9by0Ruf-$2b$04$vVYgSTfB8KVbmhbZE/k3R.-$2b$04$vVYgSTfB8KVbmhbZE/k3R.ux9A0lJUM4CZwCkHI9fifke2.rTF7MG]", "tests/test_bcrypt.py::test_hashpw_new[GtTkR6qn2QOZW-$2b$04$JfoNrR8.doieoI8..F.C1O-$2b$04$JfoNrR8.doieoI8..F.C1OQgwE3uTeuardy6lw0AjALUzOARoyf2m]", "tests/test_bcrypt.py::test_hashpw_new[zKo8vdFSnjX0f-$2b$04$HP3I0PUs7KBEzMBNFw7o3O-$2b$04$HP3I0PUs7KBEzMBNFw7o3O7f/uxaZU7aaDot1quHMgB2yrwBXsgyy]", "tests/test_bcrypt.py::test_hashpw_new[I9VfYlacJiwiK-$2b$04$xnFVhJsTzsFBTeP3PpgbMe-$2b$04$xnFVhJsTzsFBTeP3PpgbMeMREb6rdKV9faW54Sx.yg9plf4jY8qT6]", "tests/test_bcrypt.py::test_hashpw_new[VFPO7YXnHQbQO-$2b$04$WQp9.igoLqVr6Qk70mz6xu-$2b$04$WQp9.igoLqVr6Qk70mz6xuRxE0RttVXXdukpR9N54x17ecad34ZF6]", "tests/test_bcrypt.py::test_hashpw_new[VDx5BdxfxstYk-$2b$04$xgZtlonpAHSU/njOCdKztO-$2b$04$xgZtlonpAHSU/njOCdKztOPuPFzCNVpB4LGicO4/OGgHv.uKHkwsS]", "tests/test_bcrypt.py::test_hashpw_new[dEe6XfVGrrfSH-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.GNj3aO0lb1E5E9UumYGKjP9BYqlNWJe]", "tests/test_bcrypt.py::test_hashpw_new[cTT0EAFdwJiLn-$2b$04$7/Qj7Kd8BcSahPO4khB8me-$2b$04$7/Qj7Kd8BcSahPO4khB8me4ssDJCW3r4OGYqPF87jxtrSyPj5cS5m]", "tests/test_bcrypt.py::test_hashpw_new[J8eHUDuxBB520-$2b$04$VvlCUKbTMjaxaYJ.k5juoe-$2b$04$VvlCUKbTMjaxaYJ.k5juoecpG/7IzcH1AkmqKi.lIZMVIOLClWAk.]", "tests/test_bcrypt.py::test_hashpw_new[U*U-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW]", "tests/test_bcrypt.py::test_hashpw_new[U*U*-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK]", "tests/test_bcrypt.py::test_hashpw_new[U*U*U-$2a$05$XXXXXXXXXXXXXXXXXXXXXO-$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a]", "tests/test_bcrypt.py::test_hashpw_new[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789chars", "tests/test_bcrypt.py::test_hashpw_new[\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaachars", "tests/test_bcrypt.py::test_hashpw_new[\\xa3-$2a$05$/OK.fbVrR/bpIqNJ5ianF.-$2a$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq]", "tests/test_bcrypt.py::test_checkpw[Kk4DQuMMfZL9o-$2b$04$cVWp4XaNU8a4v1uMRum2SO-$2b$04$cVWp4XaNU8a4v1uMRum2SO026BWLIoQMD/TXg5uZV.0P.uO8m3YEm]", "tests/test_bcrypt.py::test_checkpw[9IeRXmnGxMYbs-$2b$04$pQ7gRO7e6wx/936oXhNjrO-$2b$04$pQ7gRO7e6wx/936oXhNjrOUNOHL1D0h1N2IDbJZYs.1ppzSof6SPy]", "tests/test_bcrypt.py::test_checkpw[xVQVbwa1S0M8r-$2b$04$SQe9knOzepOVKoYXo9xTte-$2b$04$SQe9knOzepOVKoYXo9xTteNYr6MBwVz4tpriJVe3PNgYufGIsgKcW]", "tests/test_bcrypt.py::test_checkpw[Zfgr26LWd22Za-$2b$04$eH8zX.q5Q.j2hO1NkVYJQO-$2b$04$eH8zX.q5Q.j2hO1NkVYJQOM6KxntS/ow3.YzVmFrE4t//CoF4fvne]", "tests/test_bcrypt.py::test_checkpw[Tg4daC27epFBE-$2b$04$ahiTdwRXpUG2JLRcIznxc.-$2b$04$ahiTdwRXpUG2JLRcIznxc.s1.ydaPGD372bsGs8NqyYjLY1inG5n2]", "tests/test_bcrypt.py::test_checkpw[xhQPMmwh5ALzW-$2b$04$nQn78dV0hGHf5wUBe0zOFu-$2b$04$nQn78dV0hGHf5wUBe0zOFu8n07ZbWWOKoGasZKRspZxtt.vBRNMIy]", "tests/test_bcrypt.py::test_checkpw[59je8h5Gj71tg-$2b$04$cvXudZ5ugTg95W.rOjMITu-$2b$04$cvXudZ5ugTg95W.rOjMITuM1jC0piCl3zF5cmGhzCibHZrNHkmckG]", "tests/test_bcrypt.py::test_checkpw[wT4fHJa2N9WSW-$2b$04$YYjtiq4Uh88yUsExO0RNTu-$2b$04$YYjtiq4Uh88yUsExO0RNTuEJ.tZlsONac16A8OcLHleWFjVawfGvO]", "tests/test_bcrypt.py::test_checkpw[uSgFRnQdOgm4S-$2b$04$WLTjgY/pZSyqX/fbMbJzf.-$2b$04$WLTjgY/pZSyqX/fbMbJzf.qxCeTMQOzgL.CimRjMHtMxd/VGKojMu]", "tests/test_bcrypt.py::test_checkpw[tEPtJZXur16Vg-$2b$04$2moPs/x/wnCfeQ5pCheMcu-$2b$04$2moPs/x/wnCfeQ5pCheMcuSJQ/KYjOZG780UjA/SiR.KsYWNrC7SG]", "tests/test_bcrypt.py::test_checkpw[vvho8C6nlVf9K-$2b$04$HrEYC/AQ2HS77G78cQDZQ.-$2b$04$HrEYC/AQ2HS77G78cQDZQ.r44WGcruKw03KHlnp71yVQEwpsi3xl2]", "tests/test_bcrypt.py::test_checkpw[5auCCY9by0Ruf-$2b$04$vVYgSTfB8KVbmhbZE/k3R.-$2b$04$vVYgSTfB8KVbmhbZE/k3R.ux9A0lJUM4CZwCkHI9fifke2.rTF7MG]", "tests/test_bcrypt.py::test_checkpw[GtTkR6qn2QOZW-$2b$04$JfoNrR8.doieoI8..F.C1O-$2b$04$JfoNrR8.doieoI8..F.C1OQgwE3uTeuardy6lw0AjALUzOARoyf2m]", "tests/test_bcrypt.py::test_checkpw[zKo8vdFSnjX0f-$2b$04$HP3I0PUs7KBEzMBNFw7o3O-$2b$04$HP3I0PUs7KBEzMBNFw7o3O7f/uxaZU7aaDot1quHMgB2yrwBXsgyy]", "tests/test_bcrypt.py::test_checkpw[I9VfYlacJiwiK-$2b$04$xnFVhJsTzsFBTeP3PpgbMe-$2b$04$xnFVhJsTzsFBTeP3PpgbMeMREb6rdKV9faW54Sx.yg9plf4jY8qT6]", "tests/test_bcrypt.py::test_checkpw[VFPO7YXnHQbQO-$2b$04$WQp9.igoLqVr6Qk70mz6xu-$2b$04$WQp9.igoLqVr6Qk70mz6xuRxE0RttVXXdukpR9N54x17ecad34ZF6]", "tests/test_bcrypt.py::test_checkpw[VDx5BdxfxstYk-$2b$04$xgZtlonpAHSU/njOCdKztO-$2b$04$xgZtlonpAHSU/njOCdKztOPuPFzCNVpB4LGicO4/OGgHv.uKHkwsS]", "tests/test_bcrypt.py::test_checkpw[dEe6XfVGrrfSH-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.GNj3aO0lb1E5E9UumYGKjP9BYqlNWJe]", "tests/test_bcrypt.py::test_checkpw[cTT0EAFdwJiLn-$2b$04$7/Qj7Kd8BcSahPO4khB8me-$2b$04$7/Qj7Kd8BcSahPO4khB8me4ssDJCW3r4OGYqPF87jxtrSyPj5cS5m]", "tests/test_bcrypt.py::test_checkpw[J8eHUDuxBB520-$2b$04$VvlCUKbTMjaxaYJ.k5juoe-$2b$04$VvlCUKbTMjaxaYJ.k5juoecpG/7IzcH1AkmqKi.lIZMVIOLClWAk.]", "tests/test_bcrypt.py::test_checkpw[U*U-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW]", "tests/test_bcrypt.py::test_checkpw[U*U*-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK]", "tests/test_bcrypt.py::test_checkpw[U*U*U-$2a$05$XXXXXXXXXXXXXXXXXXXXXO-$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a]", "tests/test_bcrypt.py::test_checkpw[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789chars", "tests/test_bcrypt.py::test_checkpw[\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaachars", "tests/test_bcrypt.py::test_checkpw[\\xa3-$2a$05$/OK.fbVrR/bpIqNJ5ianF.-$2a$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq]", "tests/test_bcrypt.py::test_hashpw_existing[Kk4DQuMMfZL9o-$2b$04$cVWp4XaNU8a4v1uMRum2SO-$2b$04$cVWp4XaNU8a4v1uMRum2SO026BWLIoQMD/TXg5uZV.0P.uO8m3YEm]", "tests/test_bcrypt.py::test_hashpw_existing[9IeRXmnGxMYbs-$2b$04$pQ7gRO7e6wx/936oXhNjrO-$2b$04$pQ7gRO7e6wx/936oXhNjrOUNOHL1D0h1N2IDbJZYs.1ppzSof6SPy]", "tests/test_bcrypt.py::test_hashpw_existing[xVQVbwa1S0M8r-$2b$04$SQe9knOzepOVKoYXo9xTte-$2b$04$SQe9knOzepOVKoYXo9xTteNYr6MBwVz4tpriJVe3PNgYufGIsgKcW]", "tests/test_bcrypt.py::test_hashpw_existing[Zfgr26LWd22Za-$2b$04$eH8zX.q5Q.j2hO1NkVYJQO-$2b$04$eH8zX.q5Q.j2hO1NkVYJQOM6KxntS/ow3.YzVmFrE4t//CoF4fvne]", "tests/test_bcrypt.py::test_hashpw_existing[Tg4daC27epFBE-$2b$04$ahiTdwRXpUG2JLRcIznxc.-$2b$04$ahiTdwRXpUG2JLRcIznxc.s1.ydaPGD372bsGs8NqyYjLY1inG5n2]", "tests/test_bcrypt.py::test_hashpw_existing[xhQPMmwh5ALzW-$2b$04$nQn78dV0hGHf5wUBe0zOFu-$2b$04$nQn78dV0hGHf5wUBe0zOFu8n07ZbWWOKoGasZKRspZxtt.vBRNMIy]", "tests/test_bcrypt.py::test_hashpw_existing[59je8h5Gj71tg-$2b$04$cvXudZ5ugTg95W.rOjMITu-$2b$04$cvXudZ5ugTg95W.rOjMITuM1jC0piCl3zF5cmGhzCibHZrNHkmckG]", "tests/test_bcrypt.py::test_hashpw_existing[wT4fHJa2N9WSW-$2b$04$YYjtiq4Uh88yUsExO0RNTu-$2b$04$YYjtiq4Uh88yUsExO0RNTuEJ.tZlsONac16A8OcLHleWFjVawfGvO]", "tests/test_bcrypt.py::test_hashpw_existing[uSgFRnQdOgm4S-$2b$04$WLTjgY/pZSyqX/fbMbJzf.-$2b$04$WLTjgY/pZSyqX/fbMbJzf.qxCeTMQOzgL.CimRjMHtMxd/VGKojMu]", "tests/test_bcrypt.py::test_hashpw_existing[tEPtJZXur16Vg-$2b$04$2moPs/x/wnCfeQ5pCheMcu-$2b$04$2moPs/x/wnCfeQ5pCheMcuSJQ/KYjOZG780UjA/SiR.KsYWNrC7SG]", "tests/test_bcrypt.py::test_hashpw_existing[vvho8C6nlVf9K-$2b$04$HrEYC/AQ2HS77G78cQDZQ.-$2b$04$HrEYC/AQ2HS77G78cQDZQ.r44WGcruKw03KHlnp71yVQEwpsi3xl2]", "tests/test_bcrypt.py::test_hashpw_existing[5auCCY9by0Ruf-$2b$04$vVYgSTfB8KVbmhbZE/k3R.-$2b$04$vVYgSTfB8KVbmhbZE/k3R.ux9A0lJUM4CZwCkHI9fifke2.rTF7MG]", "tests/test_bcrypt.py::test_hashpw_existing[GtTkR6qn2QOZW-$2b$04$JfoNrR8.doieoI8..F.C1O-$2b$04$JfoNrR8.doieoI8..F.C1OQgwE3uTeuardy6lw0AjALUzOARoyf2m]", "tests/test_bcrypt.py::test_hashpw_existing[zKo8vdFSnjX0f-$2b$04$HP3I0PUs7KBEzMBNFw7o3O-$2b$04$HP3I0PUs7KBEzMBNFw7o3O7f/uxaZU7aaDot1quHMgB2yrwBXsgyy]", "tests/test_bcrypt.py::test_hashpw_existing[I9VfYlacJiwiK-$2b$04$xnFVhJsTzsFBTeP3PpgbMe-$2b$04$xnFVhJsTzsFBTeP3PpgbMeMREb6rdKV9faW54Sx.yg9plf4jY8qT6]", "tests/test_bcrypt.py::test_hashpw_existing[VFPO7YXnHQbQO-$2b$04$WQp9.igoLqVr6Qk70mz6xu-$2b$04$WQp9.igoLqVr6Qk70mz6xuRxE0RttVXXdukpR9N54x17ecad34ZF6]", "tests/test_bcrypt.py::test_hashpw_existing[VDx5BdxfxstYk-$2b$04$xgZtlonpAHSU/njOCdKztO-$2b$04$xgZtlonpAHSU/njOCdKztOPuPFzCNVpB4LGicO4/OGgHv.uKHkwsS]", "tests/test_bcrypt.py::test_hashpw_existing[dEe6XfVGrrfSH-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.-$2b$04$2Siw3Nv3Q/gTOIPetAyPr.GNj3aO0lb1E5E9UumYGKjP9BYqlNWJe]", "tests/test_bcrypt.py::test_hashpw_existing[cTT0EAFdwJiLn-$2b$04$7/Qj7Kd8BcSahPO4khB8me-$2b$04$7/Qj7Kd8BcSahPO4khB8me4ssDJCW3r4OGYqPF87jxtrSyPj5cS5m]", "tests/test_bcrypt.py::test_hashpw_existing[J8eHUDuxBB520-$2b$04$VvlCUKbTMjaxaYJ.k5juoe-$2b$04$VvlCUKbTMjaxaYJ.k5juoecpG/7IzcH1AkmqKi.lIZMVIOLClWAk.]", "tests/test_bcrypt.py::test_hashpw_existing[U*U-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW]", "tests/test_bcrypt.py::test_hashpw_existing[U*U*-$2a$05$CCCCCCCCCCCCCCCCCCCCC.-$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK]", "tests/test_bcrypt.py::test_hashpw_existing[U*U*U-$2a$05$XXXXXXXXXXXXXXXXXXXXXO-$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a]", "tests/test_bcrypt.py::test_hashpw_existing[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789chars", "tests/test_bcrypt.py::test_hashpw_existing[\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaa\\xaachars", "tests/test_bcrypt.py::test_hashpw_existing[\\xa3-$2a$05$/OK.fbVrR/bpIqNJ5ianF.-$2a$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq]", "tests/test_bcrypt.py::test_checkpw_2y_prefix[\\xa3-$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq-$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq]", "tests/test_bcrypt.py::test_checkpw_2y_prefix[\\xff\\xff\\xa3-$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e-$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e]", "tests/test_bcrypt.py::test_hashpw_invalid", "tests/test_bcrypt.py::test_checkpw_wrong_password", "tests/test_bcrypt.py::test_checkpw_bad_salt", "tests/test_bcrypt.py::test_checkpw_str_password", "tests/test_bcrypt.py::test_checkpw_str_salt", "tests/test_bcrypt.py::test_hashpw_str_password", "tests/test_bcrypt.py::test_hashpw_str_salt", "tests/test_bcrypt.py::test_checkpw_nul_byte", "tests/test_bcrypt.py::test_hashpw_nul_byte", "tests/test_bcrypt.py::test_kdf[4-password-salt-[\\xbf\\x0c\\xc2\\x93X\\x7f\\x1c65U\\'ye\\x98\\xd4~W\\x90q\\xbfB~\\x9d\\x8f\\xbe\\x84*\\xba4\\xd9]", "tests/test_bcrypt.py::test_kdf[4-password-\\x00-\\xc1+Vb5\\xee\\xe0L!%\\x98\\x97\\nW\\x9ag]", "tests/test_bcrypt.py::test_kdf[4-\\x00-salt-`Q\\xbe\\x18\\xc2\\xf4\\xf8,\\xbf\\x0e\\xfe\\xe5G\\x1bK\\xb9]", "tests/test_bcrypt.py::test_kdf[4-password\\x00-salt\\x00-t\\x10\\xe4L\\xf4\\xfa\\x07\\xbf\\xaa\\xc8\\xa9(\\xb1r\\x7f\\xac\\x00\\x13u\\xe7\\xbfs\\x847\\x0fH\\xef\\xd1!t0P]", "tests/test_bcrypt.py::test_kdf[4-pass\\x00wor-sa\\x00l-\\xc2\\xbf\\xfd\\x9d\\xb3\\x8fei\\xef\\xefCr\\xf4\\xde\\x83\\xc0]", "tests/test_bcrypt.py::test_kdf[4-pass\\x00word-sa\\x00lt-K\\xa4\\xac9%\\xc0\\xe8\\xd7\\xf0\\xcd\\xb6\\xbb\\x16\\x84\\xa5o]", "tests/test_bcrypt.py::test_kdf[8-password-salt-\\xe16~\\xc5\\x15\\x1a3\\xfa\\xacL\\xc1\\xc1D\\xcd#\\xfa\\x15\\xd5T\\x84\\x93\\xec\\xc9\\x9b\\x9b]\\x9c\\r;'\\xbe\\xc7b'\\xeaf\\x08\\x8b\\x84\\x9b", "tests/test_bcrypt.py::test_kdf[42-password-salt-\\x83<\\xf0\\xdc\\xf5m\\xb6V\\x08\\xe8\\xf0\\xdc\\x0c\\xe8\\x82\\xbd]", "tests/test_bcrypt.py::test_kdf[8-Lorem", "tests/test_bcrypt.py::test_kdf[8-\\r\\xb3\\xac\\x94\\xb3\\xeeS(OJ\"\\x89;<$\\xae-:b\\xf0\\xf0\\xdb\\xce\\xf8#\\xcf\\xcc\\x85HV\\xea\\x10(-", "tests/test_bcrypt.py::test_kdf[8-\\xe1\\xbd\\x88\\xce\\xb4\\xcf\\x85\\xcf\\x83\\xcf\\x83\\xce\\xb5\\xcf\\x8d\\xcf\\x82-\\xce\\xa4\\xce\\xb7\\xce\\xbb\\xce\\xad\\xce\\xbc\\xce\\xb1\\xcf\\x87\\xce\\xbf\\xcf\\x82-Cfl\\x9b\\t\\xef3\\xed\\x8c'\\xe8\\xe8\\xf3\\xe2\\xd8\\xe6]", "tests/test_bcrypt.py::test_kdf_str_password", "tests/test_bcrypt.py::test_kdf_str_salt", "tests/test_bcrypt.py::test_invalid_params[pass-$2b$04$cVWp4XaNU8a4v1uMRum2SO-10-10-TypeError]", "tests/test_bcrypt.py::test_invalid_params[password-salt-10-10-TypeError]", "tests/test_bcrypt.py::test_invalid_params[-$2b$04$cVWp4XaNU8a4v1uMRum2SO-10-10-ValueError]", "tests/test_bcrypt.py::test_invalid_params[password--10-10-ValueError]", "tests/test_bcrypt.py::test_invalid_params[password-$2b$04$cVWp4XaNU8a4v1uMRum2SO-0-10-ValueError]", "tests/test_bcrypt.py::test_invalid_params[password-$2b$04$cVWp4XaNU8a4v1uMRum2SO--3-10-ValueError]", "tests/test_bcrypt.py::test_invalid_params[password-$2b$04$cVWp4XaNU8a4v1uMRum2SO-513-10-ValueError]", "tests/test_bcrypt.py::test_invalid_params[password-$2b$04$cVWp4XaNU8a4v1uMRum2SO-20-0-ValueError]", "tests/test_bcrypt.py::test_bcrypt_assert", "tests/test_bcrypt.py::test_2a_wraparound_bug" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2016-06-30 16:28:30+00:00
apache-2.0
4,713
pyca__service-identity-42
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6eb6bd7..db08cdd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,7 +67,7 @@ jobs: run: "check-wheel-contents dist/*.whl" - name: "Check long_description" run: "python -m twine check dist/*" - + install-dev: strategy: matrix: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 14175b2..3850ab0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,18 +7,18 @@ repos: language_version: python3.8 - repo: https://github.com/PyCQA/isort - rev: 5.7.0 + rev: 5.8.0 hooks: - id: isort additional_dependencies: [toml] language_version: python3.8 - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.4 + - repo: https://github.com/pycqa/flake8 + rev: 3.9.0 hooks: - id: flake8 - language_version: python3.8 additional_dependencies: [flake8-bugbear] + language_version: python3.8 - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.4.0 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ede0a8b..f3c7262 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,7 +7,7 @@ Versions follow `CalVer <https://calver.org>`_ with a strict backwards compatibi The third digit is only for regressions. -20.1.0 (UNRELEASED) +21.1.0 (UNRELEASED) ------------------- @@ -30,7 +30,8 @@ Deprecations: Changes: ^^^^^^^^ -*none* +- ``service_identity.exceptions.VerificationError`` can now be pickled and is overall more well-behaved as an exception. + This raises the requirement of ``attrs`` to 19.1.0. ---- diff --git a/setup.py b/setup.py index f5e4073..21cca45 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ CLASSIFIERS = [ "Topic :: Software Development :: Libraries :: Python Modules", ] INSTALL_REQUIRES = [ - "attrs>=17.4.0", + "attrs>=19.1.0", "ipaddress; python_version<'3.3'", "pyasn1-modules", # Place pyasn1 after pyasn1-modules to workaround setuptools install bug: diff --git a/src/service_identity/__init__.py b/src/service_identity/__init__.py index 28a9223..f9d0e89 100644 --- a/src/service_identity/__init__.py +++ b/src/service_identity/__init__.py @@ -12,7 +12,7 @@ from .exceptions import ( ) -__version__ = "20.1.0.dev0" +__version__ = "21.1.0.dev0" __title__ = "service-identity" __description__ = "Service identity verification for pyOpenSSL & cryptography." diff --git a/src/service_identity/exceptions.py b/src/service_identity/exceptions.py index 4d103d1..f80c3b3 100644 --- a/src/service_identity/exceptions.py +++ b/src/service_identity/exceptions.py @@ -18,7 +18,7 @@ class SubjectAltNameWarning(DeprecationWarning): """ [email protected] [email protected](auto_exc=True) class VerificationError(Exception): """ Service identity verification failed.
pyca/service-identity
43949eb0b99c2061f13508e045f7f7d5eacc84b7
diff --git a/tests/test_common.py b/tests/test_common.py index 5f14c00..aa2744a 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, division, print_function import ipaddress +import pickle import pytest import six @@ -667,12 +668,32 @@ class TestIsIPAddress(object): class TestVerificationError(object): - """ - The __str__ returns something sane. - """ + def test_repr_str(self): + """ + The __str__ and __repr__ methods return something helpful. + """ + try: + raise VerificationError(errors=["foo"]) + except VerificationError as e: + assert repr(e) == str(e) + assert str(e) != "" + + @pytest.mark.parametrize("proto", range(0, pickle.HIGHEST_PROTOCOL + 1)) + @pytest.mark.parametrize( + "exc", + [ + VerificationError(errors=[]), + VerificationError(errors=[DNSMismatch("example.com")]), + VerificationError([]), + VerificationError([DNSMismatch("example.com")]), + ], + ) + def test_pickle(self, exc, proto): + """ + Exceptions can be pickled and unpickled. + """ + new_exc = pickle.loads(pickle.dumps(exc, proto)) - try: - raise VerificationError(errors=["foo"]) - except VerificationError as e: - assert repr(e) == str(e) - assert str(e) != "" + # Exceptions can't be compared. + assert exc.__class__ == new_exc.__class__ + assert exc.__dict__ == new_exc.__dict__
VerificationError can't be un-pickled Ran into this while trying to serialize some errors. ``` import pickle from service_identity.exceptions import VerificationError error = VerificationError(errors=[]) pickle.loads(pickle.dumps(error)) ``` ``` Traceback (most recent call last): File "foo.py", line 4, in <module> pickle.loads(pickle.dumps(error)) TypeError: __init__() missing 1 required positional argument: 'errors' ``` Maybe it needs auto_exc=True? :)
0.0
43949eb0b99c2061f13508e045f7f7d5eacc84b7
[ "tests/test_common.py::TestVerificationError::test_pickle[exc0-0]", "tests/test_common.py::TestVerificationError::test_pickle[exc0-1]", "tests/test_common.py::TestVerificationError::test_pickle[exc0-2]", "tests/test_common.py::TestVerificationError::test_pickle[exc0-3]", "tests/test_common.py::TestVerificationError::test_pickle[exc0-4]", "tests/test_common.py::TestVerificationError::test_pickle[exc0-5]", "tests/test_common.py::TestVerificationError::test_pickle[exc1-0]", "tests/test_common.py::TestVerificationError::test_pickle[exc1-1]", "tests/test_common.py::TestVerificationError::test_pickle[exc1-2]", "tests/test_common.py::TestVerificationError::test_pickle[exc1-3]", "tests/test_common.py::TestVerificationError::test_pickle[exc1-4]", "tests/test_common.py::TestVerificationError::test_pickle[exc1-5]" ]
[ "tests/test_common.py::TestVerifyServiceIdentity::test_dns_id_success", "tests/test_common.py::TestVerifyServiceIdentity::test_integration_dns_id_fail", "tests/test_common.py::TestVerifyServiceIdentity::test_ip_address_success", "tests/test_common.py::TestVerifyServiceIdentity::test_obligatory_missing", "tests/test_common.py::TestVerifyServiceIdentity::test_obligatory_mismatch", "tests/test_common.py::TestVerifyServiceIdentity::test_optional_missing", "tests/test_common.py::TestVerifyServiceIdentity::test_optional_mismatch", "tests/test_common.py::TestVerifyServiceIdentity::test_contains_optional_and_matches", "tests/test_common.py::TestContainsInstance::test_positive", "tests/test_common.py::TestContainsInstance::test_negative", "tests/test_common.py::TestDNS_ID::test_enforces_unicode", "tests/test_common.py::TestDNS_ID::test_handles_missing_idna", "tests/test_common.py::TestDNS_ID::test_ascii_works_without_idna", "tests/test_common.py::TestDNS_ID::test_idna_used_if_available_on_non_ascii", "tests/test_common.py::TestDNS_ID::test_catches_invalid_dns_ids[", "tests/test_common.py::TestDNS_ID::test_catches_invalid_dns_ids[]", "tests/test_common.py::TestDNS_ID::test_catches_invalid_dns_ids[host,name]", "tests/test_common.py::TestDNS_ID::test_catches_invalid_dns_ids[192.168.0.0]", "tests/test_common.py::TestDNS_ID::test_catches_invalid_dns_ids[::1]", "tests/test_common.py::TestDNS_ID::test_catches_invalid_dns_ids[1234]", "tests/test_common.py::TestDNS_ID::test_lowercases", "tests/test_common.py::TestDNS_ID::test_verifies_only_dns", "tests/test_common.py::TestDNS_ID::test_simple_match", "tests/test_common.py::TestDNS_ID::test_simple_mismatch", "tests/test_common.py::TestDNS_ID::test_matches", "tests/test_common.py::TestDNS_ID::test_mismatches", "tests/test_common.py::TestURI_ID::test_enforces_unicode", "tests/test_common.py::TestURI_ID::test_create_DNS_ID", "tests/test_common.py::TestURI_ID::test_lowercases", "tests/test_common.py::TestURI_ID::test_catches_missing_colon", "tests/test_common.py::TestURI_ID::test_is_only_valid_for_uri", "tests/test_common.py::TestURI_ID::test_protocol_mismatch", "tests/test_common.py::TestURI_ID::test_dns_mismatch", "tests/test_common.py::TestURI_ID::test_match", "tests/test_common.py::TestSRV_ID::test_enforces_unicode", "tests/test_common.py::TestSRV_ID::test_create_DNS_ID", "tests/test_common.py::TestSRV_ID::test_lowercases", "tests/test_common.py::TestSRV_ID::test_catches_missing_dot", "tests/test_common.py::TestSRV_ID::test_catches_missing_underscore", "tests/test_common.py::TestSRV_ID::test_is_only_valid_for_SRV", "tests/test_common.py::TestSRV_ID::test_match", "tests/test_common.py::TestSRV_ID::test_match_idna", "tests/test_common.py::TestSRV_ID::test_mismatch_service_name", "tests/test_common.py::TestSRV_ID::test_mismatch_dns", "tests/test_common.py::TestDNSPattern::test_enforces_bytes", "tests/test_common.py::TestDNSPattern::test_catches_empty", "tests/test_common.py::TestDNSPattern::test_catches_NULL_bytes", "tests/test_common.py::TestDNSPattern::test_catches_ip_address", "tests/test_common.py::TestDNSPattern::test_invalid_wildcard", "tests/test_common.py::TestURIPattern::test_enforces_bytes", "tests/test_common.py::TestURIPattern::test_catches_missing_colon", "tests/test_common.py::TestURIPattern::test_catches_wildcards", "tests/test_common.py::TestSRVPattern::test_enforces_bytes", "tests/test_common.py::TestSRVPattern::test_catches_missing_underscore", "tests/test_common.py::TestSRVPattern::test_catches_wildcards", "tests/test_common.py::TestValidateDNSWildcardPattern::test_allows_only_one_wildcard", "tests/test_common.py::TestValidateDNSWildcardPattern::test_wildcard_must_be_left_most", "tests/test_common.py::TestValidateDNSWildcardPattern::test_must_have_at_least_three_parts", "tests/test_common.py::TestValidateDNSWildcardPattern::test_valid_patterns", "tests/test_common.py::TestIPAddressPattern::test_invalid_ip", "tests/test_common.py::TestIPAddressPattern::test_verify_equal[1.1.1.1]", "tests/test_common.py::TestIPAddressPattern::test_verify_equal[::1]", "tests/test_common.py::TestFindMatches::test_one_match", "tests/test_common.py::TestFindMatches::test_no_match", "tests/test_common.py::TestFindMatches::test_multiple_matches", "tests/test_common.py::TestIsIPAddress::test_ips[127.0.0.1_0]", "tests/test_common.py::TestIsIPAddress::test_ips[127.0.0.1_1]", "tests/test_common.py::TestIsIPAddress::test_ips[172.16.254.12]", "tests/test_common.py::TestIsIPAddress::test_ips[*.0.0.1]", "tests/test_common.py::TestIsIPAddress::test_ips[::1]", "tests/test_common.py::TestIsIPAddress::test_ips[*::1]", "tests/test_common.py::TestIsIPAddress::test_ips[2001:0db8:0000:0000:0000:ff00:0042:8329]", "tests/test_common.py::TestIsIPAddress::test_ips[2001:0db8::ff00:0042:8329]", "tests/test_common.py::TestIsIPAddress::test_not_ips[*.twistedmatrix.com]", "tests/test_common.py::TestIsIPAddress::test_not_ips[twistedmatrix.com]", "tests/test_common.py::TestIsIPAddress::test_not_ips[mail.google.com]", "tests/test_common.py::TestIsIPAddress::test_not_ips[omega7.de]", "tests/test_common.py::TestIsIPAddress::test_not_ips[omega7]", "tests/test_common.py::TestIsIPAddress::test_not_ips[127.\\xff.0.1]", "tests/test_common.py::TestVerificationError::test_repr_str", "tests/test_common.py::TestVerificationError::test_pickle[exc2-0]", "tests/test_common.py::TestVerificationError::test_pickle[exc2-1]", "tests/test_common.py::TestVerificationError::test_pickle[exc2-2]", "tests/test_common.py::TestVerificationError::test_pickle[exc2-3]", "tests/test_common.py::TestVerificationError::test_pickle[exc2-4]", "tests/test_common.py::TestVerificationError::test_pickle[exc2-5]", "tests/test_common.py::TestVerificationError::test_pickle[exc3-0]", "tests/test_common.py::TestVerificationError::test_pickle[exc3-1]", "tests/test_common.py::TestVerificationError::test_pickle[exc3-2]", "tests/test_common.py::TestVerificationError::test_pickle[exc3-3]", "tests/test_common.py::TestVerificationError::test_pickle[exc3-4]", "tests/test_common.py::TestVerificationError::test_pickle[exc3-5]" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2021-04-07 12:02:27+00:00
mit
4,714
pyca__service-identity-67
diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f32b86..f9aa8c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,12 @@ You can find out backwards-compatibility policy [here](https://github.com/pyca/s ## [Unreleased](https://github.com/pyca/service-identity/compare/23.1.0...HEAD) +### Changed + +- If a certificate doesn't contain any `subjectAltName`s, we now raise `service_identity.exceptions.CertificateError` instead of `service_identity.exceptions.VerificationError` to make the problem easier to debug. + [#67](https://github.com/pyca/service-identity/pull/67) + + ## [23.1.0](https://github.com/pyca/service-identity/compare/21.1.0...23.1.0) - 2023-06-14 ### Removed diff --git a/src/service_identity/cryptography.py b/src/service_identity/cryptography.py index 9397fcf..4585525 100644 --- a/src/service_identity/cryptography.py +++ b/src/service_identity/cryptography.py @@ -40,22 +40,31 @@ __all__ = ["verify_certificate_hostname"] def verify_certificate_hostname( certificate: Certificate, hostname: str ) -> None: - """ + r""" Verify whether *certificate* is valid for *hostname*. - .. note:: Nothing is verified about the *authority* of the certificate; - the caller must verify that the certificate chains to an appropriate - trust root themselves. + .. note:: + Nothing is verified about the *authority* of the certificate; + the caller must verify that the certificate chains to an appropriate + trust root themselves. + + Args: + certificate: A *cryptography* X509 certificate object. + + hostname: The hostname that *certificate* should be valid for. - :param certificate: A *cryptography* X509 certificate object. - :param hostname: The hostname that *certificate* should be valid for. + Raises: + service_identity.VerificationError: + If *certificate* is not valid for *hostname*. - :raises service_identity.VerificationError: If *certificate* is not valid - for *hostname*. - :raises service_identity.CertificateError: If *certificate* contains - invalid / unexpected data. + service_identity.CertificateError: + If *certificate* contains invalid / unexpected data. This includes + the case where the certificate contains no `subjectAltName`\ s. - :returns: ``None`` + .. versionchanged:: 24.1.0 + :exc:`~service_identity.CertificateError` is raised if the certificate + contains no ``subjectAltName``\ s instead of + :exc:`~service_identity.VerificationError`. """ verify_service_identity( cert_patterns=extract_patterns(certificate), @@ -67,25 +76,35 @@ def verify_certificate_hostname( def verify_certificate_ip_address( certificate: Certificate, ip_address: str ) -> None: - """ + r""" Verify whether *certificate* is valid for *ip_address*. - .. note:: Nothing is verified about the *authority* of the certificate; - the caller must verify that the certificate chains to an appropriate - trust root themselves. + .. note:: + Nothing is verified about the *authority* of the certificate; + the caller must verify that the certificate chains to an appropriate + trust root themselves. + + Args: + certificate: A *cryptography* X509 certificate object. - :param certificate: A *cryptography* X509 certificate object. - :param ip_address: The IP address that *connection* should be valid - for. Can be an IPv4 or IPv6 address. + ip_address: + The IP address that *connection* should be valid for. Can be an + IPv4 or IPv6 address. - :raises service_identity.VerificationError: If *certificate* is not valid - for *ip_address*. - :raises service_identity.CertificateError: If *certificate* contains - invalid / unexpected data. + Raises: + service_identity.VerificationError: + If *certificate* is not valid for *ip_address*. - :returns: ``None`` + service_identity.CertificateError: + If *certificate* contains invalid / unexpected data. This includes + the case where the certificate contains no ``subjectAltName``\ s. .. versionadded:: 18.1.0 + + .. versionchanged:: 24.1.0 + :exc:`~service_identity.CertificateError` is raised if the certificate + contains no ``subjectAltName``\ s instead of + :exc:`~service_identity.VerificationError`. """ verify_service_identity( cert_patterns=extract_patterns(certificate), @@ -101,9 +120,11 @@ def extract_patterns(cert: Certificate) -> Sequence[CertificatePattern]: """ Extract all valid ID patterns from a certificate for service verification. - :param cert: The certificate to be dissected. + Args: + cert: The certificate to be dissected. - :return: List of IDs. + Returns: + List of IDs. .. versionchanged:: 23.1.0 ``commonName`` is not used as a fallback anymore. diff --git a/src/service_identity/hazmat.py b/src/service_identity/hazmat.py index 19611d8..e8d5e75 100644 --- a/src/service_identity/hazmat.py +++ b/src/service_identity/hazmat.py @@ -50,6 +50,11 @@ def verify_service_identity( *obligatory_ids* must be both present and match. *optional_ids* must match if a pattern of the respective type is present. """ + if not cert_patterns: + raise CertificateError( + "Certificate does not contain any `subjectAltName`s." + ) + errors = [] matches = _find_matches(cert_patterns, obligatory_ids) + _find_matches( cert_patterns, optional_ids diff --git a/src/service_identity/pyopenssl.py b/src/service_identity/pyopenssl.py index 30b5d58..0ed88bc 100644 --- a/src/service_identity/pyopenssl.py +++ b/src/service_identity/pyopenssl.py @@ -37,19 +37,28 @@ __all__ = ["verify_hostname"] def verify_hostname(connection: Connection, hostname: str) -> None: - """ + r""" Verify whether the certificate of *connection* is valid for *hostname*. - :param connection: A pyOpenSSL connection object. - :param hostname: The hostname that *connection* should be connected to. + Args: + connection: A pyOpenSSL connection object. + + hostname: The hostname that *connection* should be connected to. + + Raises: + service_identity.VerificationError: + If *connection* does not provide a certificate that is valid for + *hostname*. - :raises service_identity.VerificationError: If *connection* does not - provide a certificate that is valid for *hostname*. - :raises service_identity.CertificateError: If the certificate chain of - *connection* contains a certificate that contains invalid/unexpected - data. + service_identity.CertificateError: + If certificate provided by *connection* contains invalid / + unexpected data. This includes the case where the certificate + contains no ``subjectAltName``\ s. - :returns: ``None`` + .. versionchanged:: 24.1.0 + :exc:`~service_identity.CertificateError` is raised if the certificate + contains no ``subjectAltName``\ s instead of + :exc:`~service_identity.VerificationError`. """ verify_service_identity( cert_patterns=extract_patterns( @@ -61,22 +70,31 @@ def verify_hostname(connection: Connection, hostname: str) -> None: def verify_ip_address(connection: Connection, ip_address: str) -> None: - """ + r""" Verify whether the certificate of *connection* is valid for *ip_address*. - :param connection: A pyOpenSSL connection object. - :param ip_address: The IP address that *connection* should be connected to. - Can be an IPv4 or IPv6 address. + Args: + connection: A pyOpenSSL connection object. + + ip_address: + The IP address that *connection* should be connected to. Can be an + IPv4 or IPv6 address. - :raises service_identity.VerificationError: If *connection* does not - provide a certificate that is valid for *ip_address*. - :raises service_identity.CertificateError: If the certificate chain of - *connection* contains a certificate that contains invalid/unexpected - data. + Raises: + service_identity.VerificationError: + If *connection* does not provide a certificate that is valid for + *ip_address*. - :returns: ``None`` + service_identity.CertificateError: + If the certificate chain of *connection* contains a certificate + that contains invalid/unexpected data. .. versionadded:: 18.1.0 + + .. versionchanged:: 24.1.0 + :exc:`~service_identity.CertificateError` is raised if the certificate + contains no ``subjectAltName``\ s instead of + :exc:`~service_identity.VerificationError`. """ verify_service_identity( cert_patterns=extract_patterns( @@ -94,9 +112,11 @@ def extract_patterns(cert: X509) -> Sequence[CertificatePattern]: """ Extract all valid ID patterns from a certificate for service verification. - :param cert: The certificate to be dissected. + Args: + cert: The certificate to be dissected. - :return: List of IDs. + Returns: + List of IDs. .. versionchanged:: 23.1.0 ``commonName`` is not used as a fallback anymore.
pyca/service-identity
66b984797d7ce503acedb73bd932b162ba46aa9e
diff --git a/tests/util.py b/tests/certificates.py similarity index 100% rename from tests/util.py rename to tests/certificates.py diff --git a/tests/test_cryptography.py b/tests/test_cryptography.py index 2c738ad..9a6e0dd 100644 --- a/tests/test_cryptography.py +++ b/tests/test_cryptography.py @@ -12,6 +12,7 @@ from service_identity.cryptography import ( verify_certificate_ip_address, ) from service_identity.exceptions import ( + CertificateError, DNSMismatch, IPAddressMismatch, VerificationError, @@ -24,7 +25,12 @@ from service_identity.hazmat import ( URIPattern, ) -from .util import PEM_CN_ONLY, PEM_DNS_ONLY, PEM_EVERYTHING, PEM_OTHER_NAME +from .certificates import ( + PEM_CN_ONLY, + PEM_DNS_ONLY, + PEM_EVERYTHING, + PEM_OTHER_NAME, +) backend = default_backend() @@ -35,6 +41,29 @@ CERT_EVERYTHING = load_pem_x509_certificate(PEM_EVERYTHING, backend) class TestPublicAPI: + def test_no_cert_patterns_hostname(self): + """ + A certificate without subjectAltNames raises a helpful + CertificateError. + """ + with pytest.raises( + CertificateError, + match="Certificate does not contain any `subjectAltName`s.", + ): + verify_certificate_hostname(X509_CN_ONLY, "example.com") + + @pytest.mark.parametrize("ip", ["203.0.113.0", "2001:db8::"]) + def test_no_cert_patterns_ip_address(self, ip): + """ + A certificate without subjectAltNames raises a helpful + CertificateError. + """ + with pytest.raises( + CertificateError, + match="Certificate does not contain any `subjectAltName`s.", + ): + verify_certificate_ip_address(X509_CN_ONLY, ip) + def test_certificate_verify_hostname_ok(self): """ verify_certificate_hostname succeeds if the hostnames match. diff --git a/tests/test_hazmat.py b/tests/test_hazmat.py index 3d28ca6..6c70f1f 100644 --- a/tests/test_hazmat.py +++ b/tests/test_hazmat.py @@ -30,8 +30,8 @@ from service_identity.hazmat import ( verify_service_identity, ) +from .certificates import DNS_IDS from .test_cryptography import CERT_EVERYTHING -from .util import DNS_IDS try: @@ -45,6 +45,18 @@ class TestVerifyServiceIdentity: Simple integration tests for verify_service_identity. """ + def test_no_cert_patterns(self): + """ + Empty cert patterns raise a helpful CertificateError. + """ + with pytest.raises( + CertificateError, + match="Certificate does not contain any `subjectAltName`s.", + ): + verify_service_identity( + cert_patterns=[], obligatory_ids=[], optional_ids=[] + ) + def test_dns_id_success(self): """ Return pairs of certificate ids and service ids on matches. diff --git a/tests/test_pyopenssl.py b/tests/test_pyopenssl.py index 2afbad4..582e107 100644 --- a/tests/test_pyopenssl.py +++ b/tests/test_pyopenssl.py @@ -21,7 +21,12 @@ from service_identity.pyopenssl import ( verify_ip_address, ) -from .util import PEM_CN_ONLY, PEM_DNS_ONLY, PEM_EVERYTHING, PEM_OTHER_NAME +from .certificates import ( + PEM_CN_ONLY, + PEM_DNS_ONLY, + PEM_EVERYTHING, + PEM_OTHER_NAME, +) if pytest.importorskip("OpenSSL"):
Raise a CertificateError if the certificate has no subjectAltName. I have created this ticket to start a conversion. Feel free to close it if you think this is not an issue. This ticket is triggerd by the converstation from https://github.com/twisted/twisted/issues/12074 It looks like if the server certificate has no subjectAltName, the verification will fail but the error is > <class 'service_identity.exceptions.VerificationError'>: VerificationError(errors=[DNSMismatch(mismatched_id=DNS_ID(hostname=b'default'))]) It's not very obvious that the issue is misisng `subjectAltName` This is related to the change from here https://github.com/pyca/service-identity/pull/52/files#diff-bf6d1c4ec44ff09a085657cc5b75da153a8cd025b8c72d4bd77d79e44cead072L144 In PR #52, if the certificate has no `subjectAltName` it is handled as a valid certificate without any match. Maybe, a `CertificateError('Certificate without subjectAltName.')` exception should be raised. Thanks
0.0
66b984797d7ce503acedb73bd932b162ba46aa9e
[ "tests/test_cryptography.py::TestPublicAPI::test_no_cert_patterns_hostname", "tests/test_cryptography.py::TestPublicAPI::test_no_cert_patterns_ip_address[203.0.113.0]", "tests/test_cryptography.py::TestPublicAPI::test_no_cert_patterns_ip_address[2001:db8::]", "tests/test_hazmat.py::TestVerifyServiceIdentity::test_no_cert_patterns" ]
[ "tests/test_cryptography.py::TestPublicAPI::test_certificate_verify_hostname_ok", "tests/test_cryptography.py::TestPublicAPI::test_certificate_verify_hostname_fail", "tests/test_cryptography.py::TestPublicAPI::test_verify_certificate_ip_address_ok[1.1.1.1]", "tests/test_cryptography.py::TestPublicAPI::test_verify_certificate_ip_address_ok[::1]", "tests/test_cryptography.py::TestPublicAPI::test_verify_ip_address_fail[1.1.1.2]", "tests/test_cryptography.py::TestPublicAPI::test_verify_ip_address_fail[::2]", "tests/test_cryptography.py::TestExtractPatterns::test_dns", "tests/test_cryptography.py::TestExtractPatterns::test_cn_ids_are_ignored", "tests/test_cryptography.py::TestExtractPatterns::test_uri", "tests/test_cryptography.py::TestExtractPatterns::test_ip", "tests/test_cryptography.py::TestExtractPatterns::test_extract_ids_deprecated", "tests/test_hazmat.py::TestVerifyServiceIdentity::test_dns_id_success", "tests/test_hazmat.py::TestVerifyServiceIdentity::test_integration_dns_id_fail", "tests/test_hazmat.py::TestVerifyServiceIdentity::test_ip_address_success", "tests/test_hazmat.py::TestVerifyServiceIdentity::test_obligatory_missing", "tests/test_hazmat.py::TestVerifyServiceIdentity::test_obligatory_mismatch", "tests/test_hazmat.py::TestVerifyServiceIdentity::test_optional_missing", "tests/test_hazmat.py::TestVerifyServiceIdentity::test_optional_mismatch", "tests/test_hazmat.py::TestVerifyServiceIdentity::test_contains_optional_and_matches", "tests/test_hazmat.py::TestContainsInstance::test_positive", "tests/test_hazmat.py::TestContainsInstance::test_negative", "tests/test_hazmat.py::TestDNS_ID::test_enforces_unicode", "tests/test_hazmat.py::TestDNS_ID::test_handles_missing_idna", "tests/test_hazmat.py::TestDNS_ID::test_ascii_works_without_idna", "tests/test_hazmat.py::TestDNS_ID::test_idna_used_if_available_on_non_ascii", "tests/test_hazmat.py::TestDNS_ID::test_catches_invalid_dns_ids[", "tests/test_hazmat.py::TestDNS_ID::test_catches_invalid_dns_ids[]", "tests/test_hazmat.py::TestDNS_ID::test_catches_invalid_dns_ids[host,name]", "tests/test_hazmat.py::TestDNS_ID::test_catches_invalid_dns_ids[192.168.0.0]", "tests/test_hazmat.py::TestDNS_ID::test_catches_invalid_dns_ids[::1]", "tests/test_hazmat.py::TestDNS_ID::test_catches_invalid_dns_ids[1234]", "tests/test_hazmat.py::TestDNS_ID::test_lowercases", "tests/test_hazmat.py::TestDNS_ID::test_verifies_only_dns", "tests/test_hazmat.py::TestDNS_ID::test_simple_match", "tests/test_hazmat.py::TestDNS_ID::test_simple_mismatch", "tests/test_hazmat.py::TestDNS_ID::test_matches", "tests/test_hazmat.py::TestDNS_ID::test_mismatches", "tests/test_hazmat.py::TestURI_ID::test_enforces_unicode", "tests/test_hazmat.py::TestURI_ID::test_create_DNS_ID", "tests/test_hazmat.py::TestURI_ID::test_lowercases", "tests/test_hazmat.py::TestURI_ID::test_catches_missing_colon", "tests/test_hazmat.py::TestURI_ID::test_is_only_valid_for_uri", "tests/test_hazmat.py::TestURI_ID::test_protocol_mismatch", "tests/test_hazmat.py::TestURI_ID::test_dns_mismatch", "tests/test_hazmat.py::TestURI_ID::test_match", "tests/test_hazmat.py::TestSRV_ID::test_enforces_unicode", "tests/test_hazmat.py::TestSRV_ID::test_create_DNS_ID", "tests/test_hazmat.py::TestSRV_ID::test_lowercases", "tests/test_hazmat.py::TestSRV_ID::test_catches_missing_dot", "tests/test_hazmat.py::TestSRV_ID::test_catches_missing_underscore", "tests/test_hazmat.py::TestSRV_ID::test_is_only_valid_for_SRV", "tests/test_hazmat.py::TestSRV_ID::test_match", "tests/test_hazmat.py::TestSRV_ID::test_match_idna", "tests/test_hazmat.py::TestSRV_ID::test_mismatch_service_name", "tests/test_hazmat.py::TestSRV_ID::test_mismatch_dns", "tests/test_hazmat.py::TestDNSPattern::test_enforces_bytes", "tests/test_hazmat.py::TestDNSPattern::test_catches_empty", "tests/test_hazmat.py::TestDNSPattern::test_catches_NULL_bytes", "tests/test_hazmat.py::TestDNSPattern::test_catches_ip_address", "tests/test_hazmat.py::TestDNSPattern::test_invalid_wildcard", "tests/test_hazmat.py::TestURIPattern::test_enforces_bytes", "tests/test_hazmat.py::TestURIPattern::test_catches_missing_colon", "tests/test_hazmat.py::TestURIPattern::test_catches_wildcards", "tests/test_hazmat.py::TestSRVPattern::test_enforces_bytes", "tests/test_hazmat.py::TestSRVPattern::test_catches_missing_underscore", "tests/test_hazmat.py::TestSRVPattern::test_catches_wildcards", "tests/test_hazmat.py::TestValidateDNSWildcardPattern::test_allows_only_one_wildcard", "tests/test_hazmat.py::TestValidateDNSWildcardPattern::test_wildcard_must_be_left_most", "tests/test_hazmat.py::TestValidateDNSWildcardPattern::test_must_have_at_least_three_parts", "tests/test_hazmat.py::TestValidateDNSWildcardPattern::test_valid_patterns", "tests/test_hazmat.py::TestIPAddressPattern::test_invalid_ip", "tests/test_hazmat.py::TestIPAddressPattern::test_verify_equal[1.1.1.1]", "tests/test_hazmat.py::TestIPAddressPattern::test_verify_equal[::1]", "tests/test_hazmat.py::TestFindMatches::test_one_match", "tests/test_hazmat.py::TestFindMatches::test_no_match", "tests/test_hazmat.py::TestFindMatches::test_multiple_matches", "tests/test_hazmat.py::TestIsIPAddress::test_ips[127.0.0.1_0]", "tests/test_hazmat.py::TestIsIPAddress::test_ips[127.0.0.1_1]", "tests/test_hazmat.py::TestIsIPAddress::test_ips[172.16.254.12]", "tests/test_hazmat.py::TestIsIPAddress::test_ips[*.0.0.1]", "tests/test_hazmat.py::TestIsIPAddress::test_ips[::1]", "tests/test_hazmat.py::TestIsIPAddress::test_ips[*::1]", "tests/test_hazmat.py::TestIsIPAddress::test_ips[2001:0db8:0000:0000:0000:ff00:0042:8329]", "tests/test_hazmat.py::TestIsIPAddress::test_ips[2001:0db8::ff00:0042:8329]", "tests/test_hazmat.py::TestIsIPAddress::test_not_ips[*.twistedmatrix.com]", "tests/test_hazmat.py::TestIsIPAddress::test_not_ips[twistedmatrix.com]", "tests/test_hazmat.py::TestIsIPAddress::test_not_ips[mail.google.com]", "tests/test_hazmat.py::TestIsIPAddress::test_not_ips[omega7.de]", "tests/test_hazmat.py::TestIsIPAddress::test_not_ips[omega7]", "tests/test_hazmat.py::TestIsIPAddress::test_not_ips[127.\\xff.0.1]", "tests/test_hazmat.py::TestVerificationError::test_repr_str", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc0-0]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc0-1]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc0-2]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc0-3]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc0-4]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc0-5]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc1-0]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc1-1]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc1-2]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc1-3]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc1-4]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc1-5]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc2-0]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc2-1]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc2-2]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc2-3]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc2-4]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc2-5]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc3-0]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc3-1]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc3-2]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc3-3]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc3-4]", "tests/test_hazmat.py::TestVerificationError::test_pickle[exc3-5]", "tests/test_pyopenssl.py::TestPublicAPI::test_verify_hostname_ok", "tests/test_pyopenssl.py::TestPublicAPI::test_verify_hostname_fail", "tests/test_pyopenssl.py::TestPublicAPI::test_verify_ip_address_ok[1.1.1.1]", "tests/test_pyopenssl.py::TestPublicAPI::test_verify_ip_address_ok[::1]", "tests/test_pyopenssl.py::TestPublicAPI::test_verify_ip_address_fail[1.1.1.2]", "tests/test_pyopenssl.py::TestPublicAPI::test_verify_ip_address_fail[::2]", "tests/test_pyopenssl.py::TestExtractPatterns::test_dns", "tests/test_pyopenssl.py::TestExtractPatterns::test_cn_ids_are_ignored", "tests/test_pyopenssl.py::TestExtractPatterns::test_uri", "tests/test_pyopenssl.py::TestExtractPatterns::test_ip", "tests/test_pyopenssl.py::TestExtractPatterns::test_extract_ids_deprecated" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks", "has_pytest_match_arg" ], "has_test_patch": true, "is_lite": false }
2024-01-13 12:15:31+00:00
mit
4,715
pycasbin__sqlalchemy-adapter-34
diff --git a/.travis.yml b/.travis.yml index ec8e9e5..5763d29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ language: python python: -- '3.4' - '3.5' - '3.6' - '3.7' +- '3.8' +- '3.9' install: - pip install -r requirements.txt - pip install coveralls diff --git a/README.md b/README.md index 37fb3e8..56ea6ed 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ SQLAlchemy Adapter for PyCasbin ==== -[![Build Status](https://www.travis-ci.org/pycasbin/sqlalchemy-adapter.svg?branch=master)](https://www.travis-ci.org/pycasbin/sqlalchemy-adapter) +[![Build Status](https://www.travis-ci.com/pycasbin/sqlalchemy-adapter.svg?branch=master)](https://www.travis-ci.com/pycasbin/sqlalchemy-adapter) [![Coverage Status](https://coveralls.io/repos/github/pycasbin/sqlalchemy-adapter/badge.svg)](https://coveralls.io/github/pycasbin/sqlalchemy-adapter) [![Version](https://img.shields.io/pypi/v/casbin_sqlalchemy_adapter.svg)](https://pypi.org/project/casbin_sqlalchemy_adapter/) [![PyPI - Wheel](https://img.shields.io/pypi/wheel/casbin_sqlalchemy_adapter.svg)](https://pypi.org/project/casbin_sqlalchemy_adapter/) diff --git a/casbin_sqlalchemy_adapter/adapter.py b/casbin_sqlalchemy_adapter/adapter.py index 9f47816..d7b3881 100644 --- a/casbin_sqlalchemy_adapter/adapter.py +++ b/casbin_sqlalchemy_adapter/adapter.py @@ -123,6 +123,12 @@ class Adapter(persist.Adapter): self._save_policy_line(ptype, rule) self._commit() + def add_policies(self, sec, ptype, rules): + """adds a policy rules to the storage.""" + for rule in rules: + self._save_policy_line(ptype, rule) + self._commit() + def remove_policy(self, sec, ptype, rule): """removes a policy rule from the storage.""" query = self._session.query(self._db_class) @@ -134,6 +140,16 @@ class Adapter(persist.Adapter): return True if r > 0 else False + def remove_policies(self, sec, ptype, rules): + """removes a policy rules from the storage.""" + query = self._session.query(self._db_class) + query = query.filter(self._db_class.ptype == ptype) + for rule in rules: + query = query.filter(or_(getattr(self._db_class, "v{}".format(i)) == v for i, v in enumerate(rule))) + query.delete() + self._commit() + + def remove_filtered_policy(self, sec, ptype, field_index, *field_values): """removes policy rules that match the filter from the storage. This is part of the Auto-Save feature.
pycasbin/sqlalchemy-adapter
09946f58d300ea5f1b0cf1991374a51aee4a785e
diff --git a/tests/test_adapter.py b/tests/test_adapter.py index a9ada02..5e1caeb 100644 --- a/tests/test_adapter.py +++ b/tests/test_adapter.py @@ -49,6 +49,15 @@ class TestConfig(TestCase): def test_add_policy(self): e = get_enforcer() + self.assertFalse(e.enforce('eve', 'data3', 'read')) + res = e.add_policies((('eve', 'data3', 'read'), ('eve', 'data4', 'read'))) + self.assertTrue(res) + self.assertTrue(e.enforce('eve', 'data3', 'read')) + self.assertTrue(e.enforce('eve', 'data4', 'read')) + + def test_add_policies(self): + e = get_enforcer() + self.assertFalse(e.enforce('eve', 'data3', 'read')) res = e.add_permission_for_user('eve', 'data3', 'read') self.assertTrue(res) @@ -76,6 +85,18 @@ class TestConfig(TestCase): e.delete_permission_for_user('alice', 'data5', 'read') self.assertFalse(e.enforce('alice', 'data5', 'read')) + def test_remove_policies(self): + e = get_enforcer() + + self.assertFalse(e.enforce('alice', 'data5', 'read')) + self.assertFalse(e.enforce('alice', 'data6', 'read')) + e.add_policies((('alice', 'data5', 'read'), ('alice', 'data6', 'read'))) + self.assertTrue(e.enforce('alice', 'data5', 'read')) + self.assertTrue(e.enforce('alice', 'data6', 'read')) + e.remove_policies((('alice', 'data5', 'read'), ('alice', 'data6', 'read'))) + self.assertFalse(e.enforce('alice', 'data5', 'read')) + self.assertFalse(e.enforce('alice', 'data6', 'read')) + def test_remove_filtered_policy(self): e = get_enforcer() @@ -139,7 +160,7 @@ class TestConfig(TestCase): def test_filtered_policy(self): e= get_enforcer() filter = Filter() - + filter.ptype = ['p'] e.load_filtered_policy(filter) self.assertTrue(e.enforce('alice', 'data1', 'read')) @@ -150,7 +171,7 @@ class TestConfig(TestCase): self.assertFalse(e.enforce('bob', 'data1', 'write')) self.assertFalse(e.enforce('bob', 'data2', 'read')) self.assertTrue(e.enforce('bob', 'data2', 'write')) - + filter.ptype = [] filter.v0 = ['alice'] e.load_filtered_policy(filter) @@ -164,7 +185,7 @@ class TestConfig(TestCase): self.assertFalse(e.enforce('bob', 'data2', 'write')) self.assertFalse(e.enforce('data2_admin', 'data2','read')) self.assertFalse(e.enforce('data2_admin', 'data2','write')) - + filter.v0 = ['bob'] e.load_filtered_policy(filter) self.assertFalse(e.enforce('alice', 'data1', 'read')) @@ -177,7 +198,7 @@ class TestConfig(TestCase): self.assertTrue(e.enforce('bob', 'data2', 'write')) self.assertFalse(e.enforce('data2_admin', 'data2','read')) self.assertFalse(e.enforce('data2_admin', 'data2','write')) - + filter.v0 = ['data2_admin'] e.load_filtered_policy(filter) self.assertTrue(e.enforce('data2_admin', 'data2','read')) @@ -203,7 +224,7 @@ class TestConfig(TestCase): self.assertTrue(e.enforce('bob', 'data2', 'write')) self.assertFalse(e.enforce('data2_admin', 'data2','read')) self.assertFalse(e.enforce('data2_admin', 'data2','write')) - + filter.v0 = [] filter.v1 = ['data1'] e.load_filtered_policy(filter) @@ -230,7 +251,7 @@ class TestConfig(TestCase): self.assertTrue(e.enforce('bob', 'data2', 'write')) self.assertTrue(e.enforce('data2_admin', 'data2','read')) self.assertTrue(e.enforce('data2_admin', 'data2','write')) - + filter.v1 = [] filter.v2 = ['read'] e.load_filtered_policy(filter) @@ -256,4 +277,4 @@ class TestConfig(TestCase): self.assertFalse(e.enforce('bob', 'data2', 'read')) self.assertTrue(e.enforce('bob', 'data2', 'write')) self.assertFalse(e.enforce('data2_admin', 'data2','read')) - self.assertTrue(e.enforce('data2_admin', 'data2','write')) \ No newline at end of file + self.assertTrue(e.enforce('data2_admin', 'data2','write'))
How should I use batch operations? it seems that there is no “add_policies” method What should I do if I implement it myself
0.0
09946f58d300ea5f1b0cf1991374a51aee4a785e
[ "tests/test_adapter.py::TestConfig::test_add_policy" ]
[ "tests/test_adapter.py::TestConfig::test_add_policies", "tests/test_adapter.py::TestConfig::test_enforcer_basic", "tests/test_adapter.py::TestConfig::test_filtered_policy", "tests/test_adapter.py::TestConfig::test_remove_filtered_policy", "tests/test_adapter.py::TestConfig::test_remove_policies", "tests/test_adapter.py::TestConfig::test_remove_policy", "tests/test_adapter.py::TestConfig::test_repr", "tests/test_adapter.py::TestConfig::test_save_policy", "tests/test_adapter.py::TestConfig::test_str" ]
{ "failed_lite_validators": [ "has_short_problem_statement", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2021-04-17 14:28:05+00:00
apache-2.0
4,716
pyccel__pyccel-775
diff --git a/pyccel/codegen/printing/ccode.py b/pyccel/codegen/printing/ccode.py index 45f6242a..9a5f4601 100644 --- a/pyccel/codegen/printing/ccode.py +++ b/pyccel/codegen/printing/ccode.py @@ -396,6 +396,17 @@ class CCodePrinter(CodePrinter): # ============ Elements ============ # + def _print_PythonAbs(self, expr): + if expr.arg.dtype is NativeReal(): + self._additional_imports.add("math") + func = "fabs" + elif expr.arg.dtype is NativeComplex(): + self._additional_imports.add("complex") + func = "cabs" + else: + func = "abs" + return "{}({})".format(func, self._print(expr.arg)) + def _print_PythonFloat(self, expr): value = self._print(expr.arg) type_name = self.find_in_dtype_registry('real', expr.precision)
pyccel/pyccel
8c73e235b4c2f302821258f7de34792e8e1bf9fe
diff --git a/tests/epyccel/test_builtins.py b/tests/epyccel/test_builtins.py new file mode 100644 index 00000000..2b597fb1 --- /dev/null +++ b/tests/epyccel/test_builtins.py @@ -0,0 +1,41 @@ +# pylint: disable=missing-function-docstring, missing-module-docstring/ + +from pyccel.epyccel import epyccel +from pyccel.decorators import types + +def test_abs_i(language): + @types('int') + def f1(x): + return abs(x) + + f2 = epyccel(f1, language=language) + + assert f1(0) == f2(0) + assert f1(-5) == f2(-5) + assert f1(11) == f2(11) + +def test_abs_r(language): + @types('real') + def f1(x): + return abs(x) + + f2 = epyccel(f1, language=language) + + assert f1(0.00000) == f2(0.00000) + assert f1(-3.1415) == f2(-3.1415) + assert f1(2.71828) == f2(2.71828) + + + +def test_abs_c(language): + @types('complex') + def f1(x): + return abs(x) + + f2 = epyccel(f1, language=language) + + assert f1(3j + 4) == f2(3j + 4) + assert f1(3j - 4) == f2(3j - 4) + assert f1(5j + 0) == f2(5j + 0) + assert f1(0j + 5) == f2(0j + 5) + assert f1(0j + 0) == f2(0j + 0)
Builtin abs function not working in c language **Describe the bug** Builtin abs function not implemented in c language **To Reproduce** Provide code to reproduce the behavior: ```python @types('int') def f(x): return abs(x) ``` **Error : ** ERROR at code generation stage pyccel: |fatal [codegen]: first.py [3,11]| Pyccel has encountered syntax that has not been implemented yet. (<pyccel.ast.builtins.PythonAbs object at 0x7fa62ca792b0>) **Language** c
0.0
8c73e235b4c2f302821258f7de34792e8e1bf9fe
[ "tests/epyccel/test_builtins.py::test_abs_i[c]", "tests/epyccel/test_builtins.py::test_abs_r[c]", "tests/epyccel/test_builtins.py::test_abs_c[c]" ]
[]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2021-02-26 12:59:07+00:00
mit
4,717
pyccel__pyccel-780
diff --git a/pyccel/codegen/printing/ccode.py b/pyccel/codegen/printing/ccode.py index 9a5f4601..6128e2c6 100644 --- a/pyccel/codegen/printing/ccode.py +++ b/pyccel/codegen/printing/ccode.py @@ -1317,7 +1317,7 @@ class CCodePrinter(CodePrinter): return '{} = {};'.format(lhs, rhs) def _print_For(self, expr): - target = self._print(expr.target) + counter = self._print(expr.target) body = self._print(expr.body) if isinstance(expr.iterable, PythonRange): start = self._print(expr.iterable.start) @@ -1325,9 +1325,22 @@ class CCodePrinter(CodePrinter): step = self._print(expr.iterable.step ) else: raise NotImplementedError("Only iterable currently supported is Range") - return ('for ({target} = {start}; {target} < {stop}; {target} += ' - '{step})\n{{\n{body}\n}}').format(target=target, start=start, - stop=stop, step=step, body=body) + + test_step = expr.iterable.step + if isinstance(test_step, PyccelUnarySub): + test_step = expr.iterable.step.args[0] + + # testing if the step is a value or an expression + if isinstance(test_step, Literal): + op = '>' if isinstance(expr.iterable.step, PyccelUnarySub) else '<' + return ('for ({counter} = {start}; {counter} {op} {stop}; {counter} += ' + '{step})\n{{\n{body}\n}}').format(counter=counter, start=start, op=op, + stop=stop, step=step, body=body) + else: + return ( + 'for ({counter} = {start}; ({step} > 0) ? ({counter} < {stop}) : ({counter} > {stop}); {counter} += ' + '{step})\n{{\n{body}\n}}').format(counter=counter, start=start, + stop=stop, step=step, body=body) def _print_CodeBlock(self, expr): body_exprs, new_vars = expand_to_loops(expr, self._parser.get_new_variable, language_has_vectors = False) diff --git a/pyccel/codegen/printing/fcode.py b/pyccel/codegen/printing/fcode.py index 65e0a74b..a60de6c0 100644 --- a/pyccel/codegen/printing/fcode.py +++ b/pyccel/codegen/printing/fcode.py @@ -55,7 +55,7 @@ from pyccel.ast.datatypes import CustomDataType from pyccel.ast.internals import Slice -from pyccel.ast.literals import LiteralInteger, LiteralFloat +from pyccel.ast.literals import LiteralInteger, LiteralFloat, Literal from pyccel.ast.literals import LiteralTrue from pyccel.ast.literals import Nil @@ -1756,8 +1756,24 @@ class FCodePrinter(CodePrinter): def _print_PythonRange(self, expr): start = self._print(expr.start) - stop = self._print(expr.stop) + '-' + self._print(LiteralInteger(1)) step = self._print(expr.step) + + test_step = expr.step + if isinstance(test_step, PyccelUnarySub): + test_step = expr.step.args[0] + + # testing if the step is a value or an expression + if isinstance(test_step, Literal): + if isinstance(expr.step, PyccelUnarySub): + stop = PyccelAdd(expr.stop, LiteralInteger(1)) + else: + stop = PyccelMinus(expr.stop, LiteralInteger(1)) + else: + stop = IfTernaryOperator(PyccelGt(expr.step, LiteralInteger(0)), + PyccelMinus(expr.stop, LiteralInteger(1)), + PyccelAdd(expr.stop, LiteralInteger(1))) + + stop = self._print(stop) return '{0}, {1}, {2}'.format(start, stop, step) def _print_FunctionalFor(self, expr):
pyccel/pyccel
0b76b3b284884a7c8cf7b53adb5a8d37bb565855
diff --git a/tests/epyccel/modules/loops.py b/tests/epyccel/modules/loops.py index 9ee805c1..8ee87c54 100644 --- a/tests/epyccel/modules/loops.py +++ b/tests/epyccel/modules/loops.py @@ -215,3 +215,22 @@ def while_not_0( n ): while n: n -= 1 return n + +@types( int, int, int ) +def for_loop1(start, stop, step): + x = 0 + for i in range(start, stop, step): + x += i + return x + +def for_loop2(): + x = 0 + for i in range(1, 10, 1): + x += i + return x + +def for_loop3(): + x = 0 + for i in range(10, 1, -2): + x += i + return x diff --git a/tests/epyccel/test_loops.py b/tests/epyccel/test_loops.py index ef5db8b4..4956af53 100644 --- a/tests/epyccel/test_loops.py +++ b/tests/epyccel/test_loops.py @@ -184,6 +184,21 @@ def test_loop_on_real_array(language): assert np.array_equal( out1, out2 ) +def test_for_loops(language): + f1 = loops.for_loop1 + g1 = epyccel(f1, language=language) + f2 = loops.for_loop2 + g2 = epyccel(f2, language=language) + f3 = loops.for_loop2 + g3 = epyccel(f3, language=language) + + assert (f1(1,10,1) == g1(1,10,1)) + assert (f1(10,1,-1) == g1(10,1,-1)) + assert (f1(1, 10, 2) == g1(1, 10, 2)) + assert (f1(10, 1, -3) == g1(10, 1, -3)) + assert (f2() == g2()) + assert (f3() == g3()) + def test_breaks(language): f1 = loops.fizzbuzz_search_with_breaks f2 = epyccel( f1, language = language )
For Loop for loop descending order are not working in C and Fortran **Describe the bug** For Loop for loop descending order are not working in C and have some bugs in Fortran **To Reproduce** ```python for i in range(10, 1, -1): print(i) ``` ```Python >> 10 9 8 7 6 5 4 3 2 ``` ```C #include <stdlib.h> #include <stdio.h> #include <stdint.h> int main() { int64_t i; for (i = 10; i < 1; i += -1) { printf("%ld\n", i); } return 0; } ``` here the for loop condition should be changed. ```Fortran program prog_test use, intrinsic :: ISO_C_BINDING implicit none integer(C_INT64_T) :: i do i = 10_C_INT64_T, 1_C_INT64_T-1_C_INT64_T, -1_C_INT64_T print *, i end do end program prog_test ``` ```python >> 10 9 8 7 6 5 4 3 2 1 0 ``` here the end of the for loop is wrong
0.0
0b76b3b284884a7c8cf7b53adb5a8d37bb565855
[ "tests/epyccel/test_loops.py::test_for_loops[fortran]", "tests/epyccel/test_loops.py::test_for_loops[c]" ]
[ "tests/epyccel/test_loops.py::test_sum_natural_numbers[fortran]", "tests/epyccel/test_loops.py::test_sum_natural_numbers[c]", "tests/epyccel/test_loops.py::test_sum_natural_numbers[python]", "tests/epyccel/test_loops.py::test_factorial[fortran]", "tests/epyccel/test_loops.py::test_factorial[c]", "tests/epyccel/test_loops.py::test_factorial[python]", "tests/epyccel/test_loops.py::test_fibonacci[fortran]", "tests/epyccel/test_loops.py::test_fibonacci[c]", "tests/epyccel/test_loops.py::test_fibonacci[python]", "tests/epyccel/test_loops.py::test_sum_nat_numbers_while[fortran]", "tests/epyccel/test_loops.py::test_sum_nat_numbers_while[c]", "tests/epyccel/test_loops.py::test_sum_nat_numbers_while[python]", "tests/epyccel/test_loops.py::test_factorial_while[fortran]", "tests/epyccel/test_loops.py::test_factorial_while[c]", "tests/epyccel/test_loops.py::test_factorial_while[python]", "tests/epyccel/test_loops.py::test_while_not_0[fortran]", "tests/epyccel/test_loops.py::test_while_not_0[c]", "tests/epyccel/test_loops.py::test_while_not_0[python]", "tests/epyccel/test_loops.py::test_double_while_sum[fortran]", "tests/epyccel/test_loops.py::test_double_while_sum[c]", "tests/epyccel/test_loops.py::test_double_while_sum[python]", "tests/epyccel/test_loops.py::test_fibonacci_while[fortran]", "tests/epyccel/test_loops.py::test_fibonacci_while[c]", "tests/epyccel/test_loops.py::test_fibonacci_while[python]", "tests/epyccel/test_loops.py::test_double_loop[fortran]", "tests/epyccel/test_loops.py::test_double_loop[c]", "tests/epyccel/test_loops.py::test_double_loop[python]", "tests/epyccel/test_loops.py::test_double_loop_on_2d_array_C[fortran]", "tests/epyccel/test_loops.py::test_double_loop_on_2d_array_C[c]", "tests/epyccel/test_loops.py::test_double_loop_on_2d_array_C[python]", "tests/epyccel/test_loops.py::test_double_loop_on_2d_array_F[fortran]", "tests/epyccel/test_loops.py::test_double_loop_on_2d_array_F[c]", "tests/epyccel/test_loops.py::test_double_loop_on_2d_array_F[python]", "tests/epyccel/test_loops.py::test_product_loop_on_2d_array_C[fortran]", "tests/epyccel/test_loops.py::test_product_loop_on_2d_array_F[fortran]", "tests/epyccel/test_loops.py::test_map_on_1d_array[fortran]", "tests/epyccel/test_loops.py::test_enumerate_on_1d_array[fortran]", "tests/epyccel/test_loops.py::test_zip_prod[fortran]", "tests/epyccel/test_loops.py::test_loop_on_real_array[fortran]", "tests/epyccel/test_loops.py::test_loop_on_real_array[c]", "tests/epyccel/test_loops.py::test_loop_on_real_array[python]", "tests/epyccel/test_loops.py::test_for_loops[python]", "tests/epyccel/test_loops.py::test_breaks[fortran]", "tests/epyccel/test_loops.py::test_breaks[c]", "tests/epyccel/test_loops.py::test_breaks[python]", "tests/epyccel/test_loops.py::test_continue[fortran]", "tests/epyccel/test_loops.py::test_continue[c]", "tests/epyccel/test_loops.py::test_continue[python]" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2021-03-02 10:51:34+00:00
mit
4,718
pyccel__sympde-119
diff --git a/sympde/topology/analytical_mapping.py b/sympde/topology/analytical_mapping.py index d44b143..05b9760 100644 --- a/sympde/topology/analytical_mapping.py +++ b/sympde/topology/analytical_mapping.py @@ -71,8 +71,6 @@ class CollelaMapping2D(Mapping): """ Represents a Collela 2D Mapping object. - Examples - """ _expressions = {'x': '2.*(x1 + eps*sin(2.*pi*k1*x1)*sin(2.*pi*k2*x2)) - 1.', 'y': '2.*(x2 + eps*sin(2.*pi*k1*x1)*sin(2.*pi*k2*x2)) - 1.'} @@ -83,32 +81,65 @@ class CollelaMapping2D(Mapping): #============================================================================== class TorusMapping(Mapping): """ - Represents a Torus 3D Mapping object. + Parametrization of a torus (or a portion of it) of major radius R0, using + toroidal coordinates (x1, x2, x3) = (r, theta, phi), where: - Examples + - minor radius 0 <= r < R0 + - poloidal angle 0 <= theta < 2 pi + - toroidal angle 0 <= phi < 2 pi """ - _expressions = {'x': '(R0+x1*cos(x2))*cos(x3)', - 'y': '(R0+x1*cos(x2))*sin(x3)', - 'z': 'x1*sin(x2)'} + _expressions = {'x': '(R0 + x1 * cos(x2)) * cos(x3)', + 'y': '(R0 + x1 * cos(x2)) * sin(x3)', + 'z': 'x1 * sin(x2)'} - _ldim = 2 - _pdim = 2 + _ldim = 3 + _pdim = 3 #============================================================================== -class TwistedTargetMapping(Mapping): +# TODO [YG, 07.10.2022]: add test in sympde/topology/tests/test_logical_expr.py +class TorusSurfaceMapping(Mapping): """ - Represents a Twisted Target 3D Mapping object. + 3D surface obtained by "slicing" the torus above at r = a. + The parametrization uses the coordinates (x1, x2) = (theta, phi), where: - Examples + - poloidal angle 0 <= theta < 2 pi + - toroidal angle 0 <= phi < 2 pi """ - _expressions = {'x': 'c1 + (1-k)*x1*cos(x2) - D*x1**2', - 'y': 'c2 + (1+k)*x1*sin(x2)', - 'z': 'c3 + x3*x1**2*sin(2*x2)'} + _expressions = {'x': '(R0 + a * cos(x1)) * cos(x2)', + 'y': '(R0 + a * cos(x1)) * sin(x2)', + 'z': 'a * sin(x1)'} _ldim = 2 - _pdim = 2 + _pdim = 3 + +#============================================================================== +# TODO [YG, 07.10.2022]: add test in sympde/topology/tests/test_logical_expr.py +class TwistedTargetSurfaceMapping(Mapping): + """ + 3D surface obtained by "twisting" the TargetMapping out of the (x, y) plane + + """ + _expressions = {'x': 'c1 + (1-k) * x1 * cos(x2) - D *x1**2', + 'y': 'c2 + (1+k) * x1 * sin(x2)', + 'z': 'c3 + x1**2 * sin(2*x2)'} + + _ldim = 2 + _pdim = 3 + +#============================================================================== +class TwistedTargetMapping(Mapping): + """ + 3D volume obtained by "extruding" the TwistedTargetSurfaceMapping along z. + + """ + _expressions = {'x': 'c1 + (1-k) * x1 * cos(x2) - D * x1**2', + 'y': 'c2 + (1+k) * x1 * sin(x2)', + 'z': 'c3 + x3 * x1**2 * sin(2*x2)'} + + _ldim = 3 + _pdim = 3 #============================================================================== class SphericalMapping(Mapping): diff --git a/sympde/topology/callable_mapping.py b/sympde/topology/callable_mapping.py index cd94a4f..f1f4d60 100644 --- a/sympde/topology/callable_mapping.py +++ b/sympde/topology/callable_mapping.py @@ -1,8 +1,12 @@ -from sympde.utilities.utils import lambdify_sympde -from .mapping import Mapping from sympy import Symbol -class CallableMapping: +from sympde.utilities.utils import lambdify_sympde +from .mapping import Mapping, BasicCallableMapping + +__all__ = ('CallableMapping',) + +#============================================================================== +class CallableMapping(BasicCallableMapping): def __init__( self, mapping, **kwargs ): @@ -54,27 +58,28 @@ class CallableMapping: #-------------------------------------------------------------------------- # Abstract interface #-------------------------------------------------------------------------- - def __call__( self, *eta ): + def __call__(self, *eta): return tuple( f( *eta ) for f in self._func_eval) - def jacobian( self, *eta ): + def jacobian(self, *eta): return self._jacobian( *eta ) - def jacobian_inv( self, *eta ): - return self._jacobian_inv( *eta ) + def jacobian_inv(self, *eta): + """ Compute the inverse Jacobian matrix, if possible.""" + return self._jacobian_inv(*eta) - def metric( self, *eta ): + def metric(self, *eta): return self._metric( *eta ) - def metric_det( self, *eta ): + def metric_det(self, *eta): return self._metric_det( *eta ) @property - def ldim( self ): + def ldim(self): return self.symbolic_mapping.ldim @property - def pdim( self ): + def pdim(self): return self.symbolic_mapping.pdim #-------------------------------------------------------------------------- diff --git a/sympde/topology/mapping.py b/sympde/topology/mapping.py index 8304638..5c8b658 100644 --- a/sympde/topology/mapping.py +++ b/sympde/topology/mapping.py @@ -1,7 +1,5 @@ # coding: utf-8 - - - +from abc import ABC, abstractmethod from sympy import Indexed, IndexedBase, Idx from sympy import Matrix, ImmutableDenseMatrix from sympy import Function, Expr @@ -10,7 +8,6 @@ from sympy import cacheit from sympy.core import Basic from sympy.core import Symbol,Integer from sympy.core import Add, Mul, Pow - from sympy.core.numbers import ImaginaryUnit from sympy.core.containers import Tuple from sympy import S @@ -26,7 +23,6 @@ from sympde.calculus.core import PlusInterfaceOperator, MinusInterfaceOperat from sympde.calculus.core import grad, div, curl, laplace #, hessian from sympde.calculus.core import dot, inner, outer, _diff_ops from sympde.calculus.core import has, DiffOperator - from sympde.calculus.matrices import MatrixSymbolicExpr, MatrixElement, SymbolicTrace, Inverse from sympde.calculus.matrices import SymbolicDeterminant, Transpose @@ -48,6 +44,7 @@ from .derivatives import LogicalGrad_1d, LogicalGrad_2d, LogicalGrad_3d # TODO fix circular dependency between sympde.expr.evaluation and sympde.topology.mapping __all__ = ( + 'BasicCallableMapping', 'Contravariant', 'Covariant', 'InterfaceMapping', @@ -87,6 +84,52 @@ def get_logical_test_function(u): el = l_space.element(u.name) return el +#============================================================================== +class BasicCallableMapping(ABC): + """ + Transformation of coordinates, which can be evaluated. + + F: R^l -> R^p + F(eta) = x + + with l <= p + """ + @abstractmethod + def __call__(self, *eta): + """ Evaluate mapping at location eta. """ + + @abstractmethod + def jacobian(self, *eta): + """ Compute Jacobian matrix at location eta. """ + + @abstractmethod + def jacobian_inv(self, *eta): + """ Compute inverse Jacobian matrix at location eta. + An exception should be raised if the matrix is singular. + """ + + @abstractmethod + def metric(self, *eta): + """ Compute components of metric tensor at location eta. """ + + @abstractmethod + def metric_det(self, *eta): + """ Compute determinant of metric tensor at location eta. """ + + @property + @abstractmethod + def ldim(self): + """ Number of logical/parametric dimensions in mapping + (= number of eta components). + """ + + @property + @abstractmethod + def pdim(self): + """ Number of physical dimensions in mapping + (= number of x components). + """ + #============================================================================== class Mapping(BasicMapping): """ @@ -192,10 +235,10 @@ class Mapping(BasicMapping): if obj._jac is None and obj._inv_jac is None: obj._jac = Jacobian(obj).subs(list(zip(args, exprs))) - obj._inv_jac = obj._jac.inv() + obj._inv_jac = obj._jac.inv() if pdim == ldim else None elif obj._inv_jac is None: obj._jac = ImmutableDenseMatrix(sympify(obj._jac)).subs(subs) - obj._inv_jac = obj._jac.inv() + obj._inv_jac = obj._jac.inv() if pdim == ldim else None elif obj._jac is None: obj._inv_jac = ImmutableDenseMatrix(sympify(obj._inv_jac)).subs(subs) @@ -212,6 +255,31 @@ class Mapping(BasicMapping): return obj + #-------------------------------------------------------------------------- + # Callable mapping + #-------------------------------------------------------------------------- + def get_callable_mapping(self): + if self._callable_map is None: + if self._expressions is None: + msg = 'Cannot generate callable mapping without analytical expressions. '\ + 'A user-defined callable mapping of type `BasicCallableMapping` '\ + 'can be provided using the method `set_callable_mapping`.' + raise ValueError(msg) + + from sympde.topology.callable_mapping import CallableMapping + self._callable_map = CallableMapping(self) + + return self._callable_map + + def set_callable_mapping(self, F): + + if not isinstance(F, BasicCallableMapping): + raise TypeError( + f'F must be a BasicCallableMapping, got {type(F)} instead') + + self._callable_map = F + + #-------------------------------------------------------------------------- @property def name( self ): return self._name @@ -324,13 +392,6 @@ class Mapping(BasicMapping): self._expressions, self._constants, self._is_plus, self._is_minus) return tuple([a for a in args if a is not None]) - def get_callable_mapping( self ): - - if self._callable_map is None: - import sympde.topology.callable_mapping as cm - self._callable_map = cm.CallableMapping( self ) - return self._callable_map - def _eval_subs(self, old, new): return self @@ -1366,4 +1427,3 @@ class SymbolicExpr(CalculusFunction): # TODO: check if we should use 'sympy.sympify(expr)' instead else: raise NotImplementedError('Cannot translate to Sympy: {}'.format(expr)) - diff --git a/sympde/version.py b/sympde/version.py index c0d4999..5a313cc 100644 --- a/sympde/version.py +++ b/sympde/version.py @@ -1,1 +1,1 @@ -__version__ = "0.15.2" +__version__ = "0.16.0"
pyccel/sympde
70917afe80fd7f0ac044021c2843301396696f1b
diff --git a/sympde/topology/tests/test_callable_mapping.py b/sympde/topology/tests/test_callable_mapping.py index 42581ca..23462c3 100644 --- a/sympde/topology/tests/test_callable_mapping.py +++ b/sympde/topology/tests/test_callable_mapping.py @@ -1,5 +1,6 @@ import numpy as np +from sympde.topology.mapping import Mapping, BasicCallableMapping from sympde.topology.analytical_mapping import IdentityMapping, AffineMapping from sympde.topology.analytical_mapping import PolarMapping @@ -466,3 +467,54 @@ def test_polar_mapping_array(): assert np.allclose(f.jacobian_inv(xx1, xx2), J_inv, rtol=RTOL, atol=ATOL) assert np.allclose(f.metric (xx1, xx2), G , rtol=RTOL, atol=ATOL) assert np.allclose(f.metric_det (xx1, xx2), G_det, rtol=RTOL, atol=ATOL) + +#============================================================================== +def test_user_defined_callable_mapping(): + + class UserIdentity(BasicCallableMapping): + """ Identity in N dimensions. + """ + + def __init__(self, ndim): + self._ndim = ndim + + def __call__(self, *eta): + assert len(eta) == self._ndim + return eta + + def jacobian(self, *eta): + assert len(eta) == self._ndim + return np.eye(self._ndim) + + def jacobian_inv(self, *eta): + assert len(eta) == self._ndim + return np.eye(self._ndim) + + def metric(self, *eta): + assert len(eta) == self._ndim + return np.eye(self._ndim) + + def metric_det(self, *eta): + assert len(eta) == self._ndim + return 1.0 + + @property + def ldim(self): + return self._ndim + + @property + def pdim(self): + return self._ndim + + F = Mapping('F', ldim = 3, pdim = 3) # Declare undefined symbolic mapping + f = UserIdentity(3) # Create user-defined callable mapping + F.set_callable_mapping(f) # Attach callable mapping to symbolic mapping + + assert F.get_callable_mapping() is f + assert f(4, 5, 6) == (4, 5, 6) + assert np.array_equal(f.jacobian(1, 2, 3) , [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) + assert np.array_equal(f.jacobian_inv(-7, 0, 7), [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) + assert np.array_equal(f.metric(0, 1, 1) , [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) + assert f.metric_det(-5, 8, -9) == 1.0 + assert f.ldim == 3 + assert f.pdim == 3
Allow for mappings with pdim > ldim If we call `pdim` the number of dimensions of the physical domain, and `ldim` the number of dimensions of our logical domain, we currently cannot handle `pdim > ldim` because of limitations in SymPDE's `Mapping` class, but the rest of the code should be able to handle a situation where `pdim > ldim` as soon as we fix the mapping. To this end, we can copy and reuse much of the machinery that is implemented in Psydac's classes `SymbolicMapping` and `AnalyticalMapping`.
0.0
70917afe80fd7f0ac044021c2843301396696f1b
[ "sympde/topology/tests/test_callable_mapping.py::test_identity_mapping_1d", "sympde/topology/tests/test_callable_mapping.py::test_identity_mapping_2d", "sympde/topology/tests/test_callable_mapping.py::test_identity_mapping_3d", "sympde/topology/tests/test_callable_mapping.py::test_affine_mapping_1d", "sympde/topology/tests/test_callable_mapping.py::test_affine_mapping_2d", "sympde/topology/tests/test_callable_mapping.py::test_affine_mapping_3d", "sympde/topology/tests/test_callable_mapping.py::test_polar_mapping", "sympde/topology/tests/test_callable_mapping.py::test_identity_mapping_array_1d", "sympde/topology/tests/test_callable_mapping.py::test_identity_mapping_array_2d", "sympde/topology/tests/test_callable_mapping.py::test_identity_mapping_array_3d", "sympde/topology/tests/test_callable_mapping.py::test_affine_mapping_array_1d", "sympde/topology/tests/test_callable_mapping.py::test_affine_mapping_array_2d", "sympde/topology/tests/test_callable_mapping.py::test_affine_mapping_array_3d", "sympde/topology/tests/test_callable_mapping.py::test_polar_mapping_array", "sympde/topology/tests/test_callable_mapping.py::test_user_defined_callable_mapping" ]
[]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2022-10-05 13:21:21+00:00
mit
4,719
pycontribs__jenkinsapi-511
diff --git a/jenkinsapi/build.py b/jenkinsapi/build.py index a616579..fe2d063 100644 --- a/jenkinsapi/build.py +++ b/jenkinsapi/build.py @@ -179,12 +179,31 @@ class Build(JenkinsBase): def get_duration(self): return datetime.timedelta(milliseconds=self._data["duration"]) + def _get_build(self, job_name, buildno, cache): + key = (job_name, buildno) + if key not in cache: + cache[key] = self.get_jenkins_obj()[job_name].get_build(buildno) + return cache[key] + + def _get_artifact_builds(self): + data = self.poll(tree='fingerprint[fileName,original[name,number]]') + build_cache = {(self.job.name, self.buildno): self} + builds = {} + for fpinfo in data["fingerprint"]: + buildno = fpinfo["original"]["number"] + job_name = fpinfo["original"]["name"] + build = self._get_build(job_name, buildno, build_cache) + builds[fpinfo["fileName"]] = build + return builds + def get_artifacts(self): data = self.poll(tree='artifacts[relativePath,fileName]') + builds = self._get_artifact_builds() for afinfo in data["artifacts"]: url = "%s/artifact/%s" % (self.baseurl, quote(afinfo["relativePath"])) - af = Artifact(afinfo["fileName"], url, self, + fn = afinfo["fileName"] + af = Artifact(fn, url, builds.get(fn, self), relative_path=afinfo["relativePath"]) yield af
pycontribs/jenkinsapi
532152a122300013bd6a33a5dae2246ccf829127
diff --git a/jenkinsapi_tests/unittests/test_build.py b/jenkinsapi_tests/unittests/test_build.py index fd2203a..d82e0ac 100644 --- a/jenkinsapi_tests/unittests/test_build.py +++ b/jenkinsapi_tests/unittests/test_build.py @@ -160,6 +160,78 @@ class TestBuildCase(unittest.TestCase): self.assertDictEqual(params, expected) + @mock.patch.object(Build, 'poll') + def test_get_artifacts_from_other_builds(self, poll_mock): + fingerprint = { + "fingerprint": [ + { + "fileName": "artifact1.fn", + "original": { + "name": 'FooJob', + "number": 97, + }, + }, + { + "fileName": "artifact2.fn", + "original": { + "name": 'FooJob', + "number": 95, + }, + }, + { + "fileName": "artifact3.fn", + "original": { + "name": 'BarJob', + "number": 97, + }, + }, + ], + } + artifacts = { + 'artifacts': [ + { + "fileName": "artifact1.fn", + "relativePath": "dir/artifact1.fn" + }, + { + "fileName": "artifact2.fn", + "relativePath": "dir/artifact2.fn" + }, + { + "fileName": "artifact3.fn", + "relativePath": "dir/artifact3.fn" + }, + ], + } + + # set up poll for get_artifacts calls + def poll_fn(tree): + if tree == 'fingerprint[fileName,original[name,number]]': + return fingerprint + elif tree == 'artifacts[relativePath,fileName]': + return artifacts + else: + raise ValueError('bad tree') + poll_mock.side_effect = poll_fn + + # set up jenkins for retrieving other builds + foo_mock = mock.Mock() + bar_mock = mock.Mock() + self.j.get_jenkins_obj.return_value = { + 'FooJob': foo_mock, + 'BarJob': bar_mock, + } + foo_mock.get_build.return_value = 'FooJob95' + bar_mock.get_build.return_value = 'BarJob97' + + # check artifacts + artifacts = self.b.get_artifact_dict() + self.assertEqual(self.b, artifacts['artifact1.fn'].build) + self.assertEqual('FooJob95', artifacts['artifact2.fn'].build) + self.assertEqual('BarJob97', artifacts['artifact3.fn'].build) + foo_mock.get_build.assert_called_once_with(95) + bar_mock.get_build.assert_called_once_with(97) + # TEST DISABLED - DOES NOT WORK # def test_downstream(self): # expected = ['SingleJob','MultipleJobs']
Artifact save failing due to incorrect fingerprint I am trying to trigger a Jenkins build and then download the artifact generated to my system. In my case the artifact gets downloaded but probably the verification gets failed and the following gets printed on the console. ` ERROR:root:Failed request at http://jenkins:8080/fingerprint/95d55fcb03623e130e099edadca1fa93/api/python with params: None ` On my Jenkins UI the fingerprint of the file is shown as MD5: 1bccb64e60524d933fa2d3f3334ce738 I then tried the following: ` curl http://jenkins:8080/fingerprint/1bccb64e60524d933fa2d3f3334ce738/api/python --user username:password ` which gives me the required JSON response while trying the below returns ` curl http://jenkins:8080/fingerprint/95d55fcb03623e130e099edadca1fa93/api/python --user username:password ` <body><h2>HTTP ERROR 404</h2> <p>Problem accessing /fingerprint/95d55fcb03623e130e099edadca1fa93/api/python. Reason: <pre> Not Found</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/> It looks like the md5 computed by Jenkins and the md5 computed by jenkinsapi don't match. My system information: Mac OSX El Capitan 10.11.5 Python version 2.7 jenkinsapi (0.2.30) Jenkins v1.639
0.0
532152a122300013bd6a33a5dae2246ccf829127
[ "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::test_get_artifacts_from_other_builds" ]
[ "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::test_duration", "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::testName", "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::test_get_params", "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::test_get_revision_no_scm", "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::test_get_description", "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::test_get_matrix_runs", "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::test_get_causes", "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::test_get_params_different_order", "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::test_get_slave", "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::test_build_depth", "jenkinsapi_tests/unittests/test_build.py::TestBuildCase::test_timestamp" ]
{ "failed_lite_validators": [ "has_hyperlinks" ], "has_test_patch": true, "is_lite": false }
2016-10-08 00:04:42+00:00
mit
4,720
pycontribs__jenkinsapi-528
diff --git a/jenkinsapi/build.py b/jenkinsapi/build.py index 9a85060..d1f1696 100644 --- a/jenkinsapi/build.py +++ b/jenkinsapi/build.py @@ -24,6 +24,7 @@ from jenkinsapi.custom_exceptions import NoResults from jenkinsapi.custom_exceptions import JenkinsAPIException from six.moves.urllib.parse import quote +from requests import HTTPError log = logging.getLogger(__name__) @@ -480,3 +481,19 @@ class Build(JenkinsBase): url, data='', valid=[302, 200, 500, ]) return True return False + + def get_env_vars(self): + """ + Return the environment variables. + + This method is using the Environment Injector plugin: + https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin + """ + url = self.python_api_url('%s/injectedEnvVars' % self.baseurl) + try: + data = self.get_data(url, params={'depth': self.depth}) + except HTTPError as ex: + warnings.warn('Make sure the Environment Injector plugin ' + 'is installed.') + raise ex + return data['envMap'] diff --git a/jenkinsapi/job.py b/jenkinsapi/job.py index eb59f67..b503b9e 100644 --- a/jenkinsapi/job.py +++ b/jenkinsapi/job.py @@ -259,7 +259,7 @@ class Job(JenkinsBase, MutableJenkinsThing): def get_last_failed_buildnumber(self): """ - Get the numerical ID of the last good build. + Get the numerical ID of the last failed build. """ return self._buildid_for_type(buildtype="lastFailedBuild") diff --git a/jenkinsapi/node.py b/jenkinsapi/node.py index 87e032e..a49182e 100644 --- a/jenkinsapi/node.py +++ b/jenkinsapi/node.py @@ -72,6 +72,16 @@ class Node(JenkinsBase): 'key':'TEST2', 'value':'value2' } + ], + 'tool_location': [ + { + "key": "hudson.tasks.Maven$MavenInstallation$DescriptorImpl@Maven 3.0.5", + "home": "/home/apache-maven-3.0.5/" + }, + { + "key": "hudson.plugins.git.GitTool$DescriptorImpl@Default", + "home": "/home/git-3.0.5/" + }, ] } @@ -140,17 +150,21 @@ class Node(JenkinsBase): 'idleDelay': na['ondemand_idle_delay'] } + node_props = { + 'stapler-class-bag': 'true' + } if 'env' in na: - node_props = { - 'stapler-class-bag': 'true', + node_props.update({ 'hudson-slaves-EnvironmentVariablesNodeProperty': { 'env': na['env'] } - } - else: - node_props = { - 'stapler-class-bag': 'true' - } + }) + if 'tool_location' in na: + node_props.update({ + "hudson-tools-ToolLocationNodeProperty": { + "locations": na['tool_location'] + } + }) params = { 'name': self.name,
pycontribs/jenkinsapi
1ecd446dfaa45466e6a97078bedcc4257f59ffa7
diff --git a/jenkinsapi_tests/systests/conftest.py b/jenkinsapi_tests/systests/conftest.py index 89fefe6..3f3c461 100644 --- a/jenkinsapi_tests/systests/conftest.py +++ b/jenkinsapi_tests/systests/conftest.py @@ -25,7 +25,8 @@ PLUGIN_DEPENDENCIES = [ "https://updates.jenkins-ci.org/latest/nested-view.hpi", "https://updates.jenkins-ci.org/latest/ssh-slaves.hpi", "https://updates.jenkins-ci.org/latest/structs.hpi", - "http://updates.jenkins-ci.org/latest/plain-credentials.hpi" + "http://updates.jenkins-ci.org/latest/plain-credentials.hpi", + "http://updates.jenkins-ci.org/latest/envinject.hpi" ] diff --git a/jenkinsapi_tests/systests/job_configs.py b/jenkinsapi_tests/systests/job_configs.py index ce6341e..c5c3387 100644 --- a/jenkinsapi_tests/systests/job_configs.py +++ b/jenkinsapi_tests/systests/job_configs.py @@ -311,3 +311,31 @@ JOB_WITH_FILE_AND_PARAMS = """ </publishers> <buildWrappers/> </project>""".strip() + +JOB_WITH_ENV_VARS = '''\ +<?xml version="1.0" encoding="UTF-8"?><project> + <actions/> + <description/> + <keepDependencies>false</keepDependencies> + <properties/> + <scm class="hudson.scm.NullSCM"/> + <canRoam>true</canRoam> + <disabled>false</disabled> + <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> + <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> + <triggers class="vector"/> + <concurrentBuild>false</concurrentBuild> + <builders/> + <publishers/> + <buildWrappers> + <EnvInjectBuildWrapper plugin="[email protected]"> + <info> + <groovyScriptContent> + return [\'key1\': \'value1\', \'key2\': \'value2\'] + </groovyScriptContent> + <loadFilesFromMaster>false</loadFilesFromMaster> + </info> + </EnvInjectBuildWrapper> + </buildWrappers> +</project> +'''.strip() diff --git a/jenkinsapi_tests/systests/test_env_vars.py b/jenkinsapi_tests/systests/test_env_vars.py new file mode 100644 index 0000000..05dd831 --- /dev/null +++ b/jenkinsapi_tests/systests/test_env_vars.py @@ -0,0 +1,17 @@ +""" +System tests for `jenkinsapi.jenkins` module. +""" +from jenkinsapi_tests.systests.job_configs import JOB_WITH_ENV_VARS +from jenkinsapi_tests.test_utils.random_strings import random_string + + +def test_get_env_vars(jenkins): + job_name = 'get_env_vars_create1_%s' % random_string() + job = jenkins.create_job(job_name, JOB_WITH_ENV_VARS) + job.invoke(block=True) + build = job.get_last_build() + while build.is_running(): + time.sleep(0.25) + data = build.get_env_vars() + assert data['key1'] == 'value1' + assert data['key2'] == 'value2' diff --git a/jenkinsapi_tests/systests/test_nodes.py b/jenkinsapi_tests/systests/test_nodes.py index 46fb86f..c9ba26b 100644 --- a/jenkinsapi_tests/systests/test_nodes.py +++ b/jenkinsapi_tests/systests/test_nodes.py @@ -37,7 +37,13 @@ def test_create_jnlp_node(jenkins): 'node_description': 'Test JNLP Node', 'remote_fs': '/tmp', 'labels': 'systest_jnlp', - 'exclusive': True + 'exclusive': True, + 'tool_location': [ + { + "key": "hudson.tasks.Maven$MavenInstallation$DescriptorImpl@Maven 3.0.5", + "home": "/home/apache-maven-3.0.5/" + }, + ] } node = jenkins.nodes.create_node(node_name, node_dict) assert isinstance(node, Node) is True @@ -72,7 +78,13 @@ def test_create_ssh_node(jenkins): 'suffix_start_slave_cmd': '', 'retention': 'ondemand', 'ondemand_delay': 0, - 'ondemand_idle_delay': 5 + 'ondemand_idle_delay': 5, + 'tool_location': [ + { + "key": "hudson.tasks.Maven$MavenInstallation$DescriptorImpl@Maven 3.0.5", + "home": "/home/apache-maven-3.0.5/" + }, + ] } node = jenkins.nodes.create_node(node_name, node_dict) assert isinstance(node, Node) is True diff --git a/jenkinsapi_tests/unittests/configs.py b/jenkinsapi_tests/unittests/configs.py index cdcfd14..981a858 100644 --- a/jenkinsapi_tests/unittests/configs.py +++ b/jenkinsapi_tests/unittests/configs.py @@ -205,3 +205,8 @@ BUILD_SCM_DATA = { 'timestamp': 1372553675652, 'url': 'http://localhost:8080/job/git_yssrtigfds/3/' } + +BUILD_ENV_VARS = { + '_class': 'org.jenkinsci.plugins.envinject.EnvInjectVarList', + 'envMap': {'KEY': 'VALUE'} +} diff --git a/jenkinsapi_tests/unittests/test_build.py b/jenkinsapi_tests/unittests/test_build.py index 1af1bd9..a72fc91 100644 --- a/jenkinsapi_tests/unittests/test_build.py +++ b/jenkinsapi_tests/unittests/test_build.py @@ -1,3 +1,5 @@ +import requests +import warnings import pytest import pytz from . import configs @@ -154,3 +156,34 @@ def test_only_ParametersAction_parameters_considered(build): params = build.get_params() assert params == expected +def test_build_env_vars(monkeypatch, build): + def fake_get_data(cls, tree=None, params=None): + return configs.BUILD_ENV_VARS + monkeypatch.setattr(Build, 'get_data', fake_get_data) + assert build.get_env_vars() == configs.BUILD_ENV_VARS['envMap'] + +def test_build_env_vars_wo_injected_env_vars_plugin(monkeypatch, build): + def fake_get_data(cls, tree=None, params=None): + raise requests.HTTPError('404') + monkeypatch.setattr(Build, 'get_data', fake_get_data) + + with pytest.raises(requests.HTTPError) as excinfo: + with pytest.warns(None) as record: + build.get_env_vars() + assert '404' == str(excinfo.value) + assert len(record) == 1 + expected = UserWarning('Make sure the Environment Injector ' + 'plugin is installed.') + assert str(record[0].message) == str(expected) + +def test_build_env_vars_other_exception(monkeypatch, build): + def fake_get_data(cls, tree=None, params=None): + raise ValueError() + monkeypatch.setattr(Build, 'get_data', fake_get_data) + + with pytest.raises(Exception) as excinfo: + with pytest.warns(None) as record: + build.get_env_vars() + assert '' == str(excinfo.value) + assert len(record) == 0 +
support getting environment variables ##### ISSUE TYPE - Feature Idea ##### Jenkinsapi VERSION ##### Jenkins VERSION 2.9 ##### SUMMARY The REST API to get env variables from the build is present. I think it would be great if jenkinsapi supported getting these variables. https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin
0.0
1ecd446dfaa45466e6a97078bedcc4257f59ffa7
[ "jenkinsapi_tests/unittests/test_build.py::test_build_env_vars" ]
[ "jenkinsapi_tests/unittests/test_build.py::test_timestamp", "jenkinsapi_tests/unittests/test_build.py::test_name", "jenkinsapi_tests/unittests/test_build.py::test_duration", "jenkinsapi_tests/unittests/test_build.py::test_get_causes", "jenkinsapi_tests/unittests/test_build.py::test_get_description", "jenkinsapi_tests/unittests/test_build.py::test_get_slave", "jenkinsapi_tests/unittests/test_build.py::test_get_revision_no_scm", "jenkinsapi_tests/unittests/test_build.py::test_downstream", "jenkinsapi_tests/unittests/test_build.py::test_get_params", "jenkinsapi_tests/unittests/test_build.py::test_get_params_different_order", "jenkinsapi_tests/unittests/test_build.py::test_only_ParametersAction_parameters_considered" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2017-01-07 21:31:05+00:00
mit
4,721
pycontribs__jenkinsapi-594
diff --git a/jenkinsapi/build.py b/jenkinsapi/build.py index 2e142da..e220b61 100644 --- a/jenkinsapi/build.py +++ b/jenkinsapi/build.py @@ -106,7 +106,7 @@ class Build(JenkinsBase): if elem.get('_class') == 'hudson.model.ParametersAction': parameters = elem.get('parameters', {}) break - return {pair['name']: pair['value'] for pair in parameters} + return {pair['name']: pair.get('value') for pair in parameters} def get_changeset_items(self): """ diff --git a/tox.ini b/tox.ini index a5aac73..16b7cc1 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ usedevelop= commands= python -m pylint jenkinsapi python -m pycodestyle - py.test -sv --cov=jenkinsapi --cov-report=term-missing --cov-report=xml jenkinsapi_tests + py.test -sv --cov=jenkinsapi --cov-report=term-missing --cov-report=xml jenkinsapi_tests {posargs} [testenv:args] deps = -rtest-requirements.txt
pycontribs/jenkinsapi
cdd3f90e4ce5122db24e31038aeee098357313a4
diff --git a/jenkinsapi_tests/unittests/test_build.py b/jenkinsapi_tests/unittests/test_build.py index fe31972..8df3adf 100644 --- a/jenkinsapi_tests/unittests/test_build.py +++ b/jenkinsapi_tests/unittests/test_build.py @@ -157,6 +157,25 @@ def test_only_ParametersAction_parameters_considered(build): assert params == expected +def test_ParametersWithNoValueSetValueNone_issue_583(build): + """SecretParameters don't share their value in the API.""" + expected = { + 'some-secret': None, + } + build._data = { + 'actions': [ + { + '_class': 'hudson.model.ParametersAction', + 'parameters': [ + {'name': 'some-secret'}, + ] + } + ] + } + params = build.get_params() + assert params == expected + + def test_build_env_vars(monkeypatch, build): def fake_get_data(cls, tree=None, params=None): return configs.BUILD_ENV_VARS
jenkinsapi.build.get_params() fails when Job have password parameter ##### ISSUE TYPE <!--- Pick one below and delete the rest: --> - Bug Report ##### Jenkinsapi VERSION 0.3.4 ##### Jenkins VERSION Jenkins ver. 2.60.2 ##### SUMMARY When Job have Password Parameter and I try to get build parameters of this job ( jenkinsapi.build.get_params() ), procedure get_params() fails with traceback: ``` Traceback (most recent call last): File "/opt/pycharm/helpers/pydev/pydevd.py", line 1599, in <module> globals = debugger.run(setup['file'], None, None, is_module) File "/opt/pycharm/helpers/pydev/pydevd.py", line 1026, in run pydev_imports.execfile(file, globals, locals) # execute the script File "/opt/pycharm/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/tema/Pro/Jenins-job-restart/jjr.py", line 320, in <module> jjr.start() File "/home/tema/Pro/Jenins-job-restart/jjr.py", line 50, in start self.__cycle() File "/home/tema/Pro/Jenins-job-restart/jjr.py", line 100, in __cycle job_params = job_build.get_params() File "/home/tema/Pro/ve_Jenkins/lib/python3.5/site-packages/jenkinsapi/build.py", line 110, in get_params return {pair['name']: pair['value'] for pair in parameters} File "/home/tema/Pro/ve_Jenkins/lib/python3.5/site-packages/jenkinsapi/build.py", line 110, in <dictcomp> return {pair['name']: pair['value'] for pair in parameters} KeyError: 'value' ``` because value "parameters" in get_params(): `[{'name': 'BRANCH', '_class': 'hudson.model.StringParameterValue', 'value': 'staging'}, {'name': 'REPO_URL', '_class': 'hudson.model.StringParameterValue', 'value': 'git.my.com:/BB.git'}, {'name': 'NODE', '_class': 'org.jvnet.jenkins.plugins.nodelabelparameter.NodeParameterValue', 'value': 'my11'}, {'name': 'DOMAIN', '_class': 'hudson.model.StringParameterValue', 'value': 'my.lan'}, {'name': 'SETUP', '_class': 'hudson.model.BooleanParameterValue', 'value': True}, {'name': 'LAUNCH', '_class': 'hudson.model.BooleanParameterValue', 'value': True}, {'name': 'REBUILD', '_class': 'hudson.model.StringParameterValue', 'value': 'No_Force'}, {'name': 'JENKINS_TESTS', '_class': 'hudson.model.BooleanParameterValue', 'value': False}, {'name': 'DR_REGISTRY', '_class': 'hudson.model.StringParameterValue', 'value': 'dr.my.lan:5000'}, {'name': 'TESTS_LISTS', '_class': 'com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterValue', 'value': 'registration_actions'}, {'name': 'CURRENCY', '_class': 'hudson.model.StringParameterValue', 'value': 'EUR'}, {'name': 'DEFAULT_LANG_CODE', '_class': 'hudson.model.StringParameterValue', 'value': 'en'}, {'name': 'SELENIUM_HOST', '_class': 'hudson.model.StringParameterValue', 'value': my2.my.lan'}, {'name': 'GET_JS_ERRORS', '_class': 'hudson.model.BooleanParameterValue', 'value': False}, {'name': 'OPERATOR_ID', '_class': 'hudson.model.StringParameterValue', 'value': '15'}, {'name': 'OPERATOR_API_SERVER_URL', '_class': 'hudson.model.StringParameterValue', 'value': 'op.my.com:8043'}, {'name': 'USER_API_SERVER_HOST', '_class': 'hudson.model.StringParameterValue', 'value': 'cw-gm.my.com'}, {'name': 'EXTERNAL_OP_HOST', '_class': 'hudson.model.StringParameterValue', 'value': 'my.com'}, {'name': 'MOBILE_SITE_URL', '_class': 'hudson.model.StringParameterValue', 'value': 'm.my.com'}, {'name': 'BO_SERVER_HOST', '_class': 'hudson.model.StringParameterValue', 'value': 'bo.my.com'}, {'name': 'PREPROD', '_class': 'hudson.model.BooleanParameterValue', 'value': True}, {'name': 'OPERATOR_PASSWORD', '_class': 'hudson.model.PasswordParameterValue'}, {'name': 'FB_APPID', '_class': 'hudson.model.PasswordParameterValue'}, {'name': 'FB_SECRET', '_class': 'hudson.model.PasswordParameterValue'}] ` last key pairs (OPERATOR_PASSWORD FB_APPID FB_SECRET) don't have key 'value' because its "Password Parameters" ##### EXPECTED RESULTS Key 'value' must return at least an empty string. ##### ACTUAL RESULTS Procedure fails with traceback written above. ##### USEFUL INFORMATION All info in ##### SUMMARY
0.0
cdd3f90e4ce5122db24e31038aeee098357313a4
[ "jenkinsapi_tests/unittests/test_build.py::test_ParametersWithNoValueSetValueNone_issue_583" ]
[ "jenkinsapi_tests/unittests/test_build.py::test_timestamp", "jenkinsapi_tests/unittests/test_build.py::test_name", "jenkinsapi_tests/unittests/test_build.py::test_duration", "jenkinsapi_tests/unittests/test_build.py::test_get_causes", "jenkinsapi_tests/unittests/test_build.py::test_get_description", "jenkinsapi_tests/unittests/test_build.py::test_get_slave", "jenkinsapi_tests/unittests/test_build.py::test_get_revision_no_scm", "jenkinsapi_tests/unittests/test_build.py::test_downstream", "jenkinsapi_tests/unittests/test_build.py::test_get_params", "jenkinsapi_tests/unittests/test_build.py::test_get_params_different_order", "jenkinsapi_tests/unittests/test_build.py::test_only_ParametersAction_parameters_considered", "jenkinsapi_tests/unittests/test_build.py::test_build_env_vars" ]
{ "failed_lite_validators": [ "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2017-12-06 23:39:26+00:00
mit
4,722
pycontribs__jenkinsapi-682
diff --git a/jenkinsapi/utils/requester.py b/jenkinsapi/utils/requester.py index a51bf0a..5dd0716 100644 --- a/jenkinsapi/utils/requester.py +++ b/jenkinsapi/utils/requester.py @@ -40,23 +40,42 @@ class Requester(object): def __init__(self, *args, **kwargs): - if args: - try: - username, password = args - except ValueError as Error: - raise Error - else: - username = None - password = None - - baseurl = kwargs.get('baseurl', None) + username = None + password = None + ssl_verify = True + cert = None + baseurl = None + timeout = 10 + + if len(args) == 1: + username, = args + elif len(args) == 2: + username, password = args + elif len(args) == 3: + username, password, ssl_verify = args + elif len(args) == 4: + username, password, ssl_verify, cert = args + elif len(args) == 5: + username, password, ssl_verify, cert, baseurl = args + elif len(args) == 6: + username, password, ssl_verify, cert, baseurl, timeout = args + elif len(args) > 6: + raise ValueError("To much positional arguments given!") + + baseurl = kwargs.get('baseurl', baseurl) self.base_scheme = urlparse.urlsplit( baseurl).scheme if baseurl else None - self.username = username - self.password = password - self.ssl_verify = kwargs.get('ssl_verify', True) - self.cert = kwargs.get('cert', None) - self.timeout = kwargs.get('timeout', 10) + self.username = kwargs.get('username', username) + self.password = kwargs.get('password', password) + if self.username: + assert self.password, 'Please provide both username and password '\ + 'or don\'t provide them at all' + if self.password: + assert self.username, 'Please provide both username and password '\ + 'or don\'t provide them at all' + self.ssl_verify = kwargs.get('ssl_verify', ssl_verify) + self.cert = kwargs.get('cert', cert) + self.timeout = kwargs.get('timeout', timeout) def get_request_dict( self, params=None, data=None, files=None, headers=None, **kwargs):
pycontribs/jenkinsapi
a87a5cd53ad0c0566836041427539a54d7fd0cbc
diff --git a/jenkinsapi_tests/unittests/test_requester.py b/jenkinsapi_tests/unittests/test_requester.py index 2f810d9..a0fe4ab 100644 --- a/jenkinsapi_tests/unittests/test_requester.py +++ b/jenkinsapi_tests/unittests/test_requester.py @@ -5,6 +5,115 @@ from jenkinsapi.jenkins import Requester from jenkinsapi.custom_exceptions import JenkinsAPIException +def test_no_parameters_uses_default_values(): + req = Requester() + assert isinstance(req, Requester) + assert req.username is None + assert req.password is None + assert req.ssl_verify + assert req.cert is None + assert req.base_scheme is None + assert req.timeout == 10 + + +def test_all_named_parameters(): + req = Requester(username='foo', password='bar', ssl_verify=False, + cert='foobar', baseurl='http://dummy', timeout=5) + assert isinstance(req, Requester) + assert req.username == 'foo' + assert req.password == 'bar' + assert not req.ssl_verify + assert req.cert == 'foobar' + assert req.base_scheme == 'http', 'dummy' + assert req.timeout == 5 + + +def test_mix_one_unnamed_named_parameters(): + req = Requester('foo', password='bar', ssl_verify=False, cert='foobar', + baseurl='http://dummy', timeout=5) + assert isinstance(req, Requester) + assert req.username == 'foo' + assert req.password == 'bar' + assert not req.ssl_verify + assert req.cert == 'foobar' + assert req.base_scheme == 'http', 'dummy' + assert req.timeout == 5 + + +def test_mix_two_unnamed_named_parameters(): + req = Requester('foo', 'bar', ssl_verify=False, cert='foobar', + baseurl='http://dummy', timeout=5) + assert isinstance(req, Requester) + assert req.username == 'foo' + assert req.password == 'bar' + assert not req.ssl_verify + assert req.cert == 'foobar' + assert req.base_scheme == 'http', 'dummy' + assert req.timeout == 5 + + +def test_mix_three_unnamed_named_parameters(): + req = Requester('foo', 'bar', False, cert='foobar', baseurl='http://dummy', + timeout=5) + assert isinstance(req, Requester) + assert req.username == 'foo' + assert req.password == 'bar' + assert not req.ssl_verify + assert req.cert == 'foobar' + assert req.base_scheme == 'http', 'dummy' + assert req.timeout == 5 + + +def test_mix_four_unnamed_named_parameters(): + req = Requester('foo', 'bar', False, 'foobar', baseurl='http://dummy', + timeout=5) + assert isinstance(req, Requester) + assert req.username == 'foo' + assert req.password == 'bar' + assert not req.ssl_verify + assert req.cert == 'foobar' + assert req.base_scheme == 'http', 'dummy' + assert req.timeout == 5 + + +def test_mix_five_unnamed_named_parameters(): + req = Requester('foo', 'bar', False, 'foobar', 'http://dummy', timeout=5) + assert isinstance(req, Requester) + assert req.username == 'foo' + assert req.password == 'bar' + assert not req.ssl_verify + assert req.cert == 'foobar' + assert req.base_scheme == 'http', 'dummy' + assert req.timeout == 5 + + +def test_all_unnamed_parameters(): + req = Requester('foo', 'bar', False, 'foobar', 'http://dummy', 5) + assert isinstance(req, Requester) + assert req.username == 'foo' + assert req.password == 'bar' + assert not req.ssl_verify + assert req.cert == 'foobar' + assert req.base_scheme == 'http', 'dummy' + assert req.timeout == 5 + + +def test_to_much_unnamed_parameters_raises_error(): + with pytest.raises(Exception): + Requester('foo', 'bar', False, 'foobar', 'http://dummy', 5, 'test') + + +def test_username_without_password_raises_error(): + with pytest.raises(Exception): + Requester(username='foo') + Requester('foo') + + +def test_password_without_username_raises_error(): + with pytest.raises(AssertionError): + Requester(password='bar') + + def test_get_request_dict_auth(): req = Requester('foo', 'bar')
Connection failed with crumb requester as 403 Client Error: Forbidden ##### ISSUE TYPE <!--- Pick one below and delete the rest: --> - Bug Report ##### Jenkinsapi VERSION 0.3.7 ##### Jenkins VERSION Jenkins ver. 2.150.1 ##### SUMMARY <!--- Explain the problem briefly --> Looks like in the latest release the connection to a jenkins instance that has CSRF protection enabled is not working anymore. For example by executing: ``` #!/usr/bin/env python3 from jenkinsapi.jenkins import Jenkins from jenkinsapi.utils.crumb_requester import CrumbRequester jenkins = Jenkins( 'http://localhost:8080', username='test', password='test', requester=CrumbRequester( baseurl='http://localhost:8080', username='test', password='test' ) ) for job_name in jenkins.jobs: print (job_name) ``` ##### EXPECTED RESULTS <!--- What did you expect to happen when running the steps above? --> Print all the jobs currently available on the jenkins instance. In the previous version (0.3.6) the above code just worked fine. ##### ACTUAL RESULTS <!--- What actually happened? If possible run with extra verbosity (-vvvv) --> Getting 403 forbidden when instantiating a new Jenkins object. The stacktrace is: ``` ERROR:root:Failed request at http://localhost:8080/api/python with params: {'tree': 'jobs[name,color,url]'} jobs[name,color,url] Traceback (most recent call last): File "./test.py", line 11, in <module> password='test' File "/usr/local/lib/python3.6/dist-packages/jenkinsapi/jenkins.py", line 63, in __init__ JenkinsBase.__init__(self, baseurl, poll=not lazy) File "/usr/local/lib/python3.6/dist-packages/jenkinsapi/jenkinsbase.py", line 35, in __init__ self.poll() File "/usr/local/lib/python3.6/dist-packages/jenkinsapi/jenkinsbase.py", line 57, in poll data = self._poll(tree=tree) File "/usr/local/lib/python3.6/dist-packages/jenkinsapi/jenkins.py", line 68, in _poll if not tree else tree) File "/usr/local/lib/python3.6/dist-packages/jenkinsapi/jenkinsbase.py", line 81, in get_data response.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 935, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://localhost:8080/api/python?tree=jobs%5Bname%2Ccolor%2Curl%5D ``` ##### USEFUL INFORMATION <!--- For bugs, show exactly how to reproduce the problem. For new features, show how the feature would be used. --> Just run the code above using both 0.3.6 and 0.3.7 and compare output. <!--- Paste example code and full stacktrace below -->
0.0
a87a5cd53ad0c0566836041427539a54d7fd0cbc
[ "jenkinsapi_tests/unittests/test_requester.py::test_all_named_parameters", "jenkinsapi_tests/unittests/test_requester.py::test_mix_one_unnamed_named_parameters", "jenkinsapi_tests/unittests/test_requester.py::test_mix_three_unnamed_named_parameters", "jenkinsapi_tests/unittests/test_requester.py::test_mix_four_unnamed_named_parameters", "jenkinsapi_tests/unittests/test_requester.py::test_mix_five_unnamed_named_parameters", "jenkinsapi_tests/unittests/test_requester.py::test_all_unnamed_parameters", "jenkinsapi_tests/unittests/test_requester.py::test_password_without_username_raises_error" ]
[ "jenkinsapi_tests/unittests/test_requester.py::test_no_parameters_uses_default_values", "jenkinsapi_tests/unittests/test_requester.py::test_mix_two_unnamed_named_parameters", "jenkinsapi_tests/unittests/test_requester.py::test_to_much_unnamed_parameters_raises_error", "jenkinsapi_tests/unittests/test_requester.py::test_username_without_password_raises_error", "jenkinsapi_tests/unittests/test_requester.py::test_get_request_dict_auth", "jenkinsapi_tests/unittests/test_requester.py::test_get_request_dict_wrong_params", "jenkinsapi_tests/unittests/test_requester.py::test_get_request_dict_correct_params", "jenkinsapi_tests/unittests/test_requester.py::test_get_request_dict_wrong_headers", "jenkinsapi_tests/unittests/test_requester.py::test_get_request_dict_correct_headers", "jenkinsapi_tests/unittests/test_requester.py::test_get_request_dict_data_passed", "jenkinsapi_tests/unittests/test_requester.py::test_get_request_dict_data_not_passed", "jenkinsapi_tests/unittests/test_requester.py::test_get_url_get", "jenkinsapi_tests/unittests/test_requester.py::test_get_url_post", "jenkinsapi_tests/unittests/test_requester.py::test_post_xml_empty_xml", "jenkinsapi_tests/unittests/test_requester.py::test_post_xml_and_confirm_status_some_xml", "jenkinsapi_tests/unittests/test_requester.py::test_post_and_confirm_status_empty_data", "jenkinsapi_tests/unittests/test_requester.py::test_post_and_confirm_status_some_data", "jenkinsapi_tests/unittests/test_requester.py::test_post_and_confirm_status_bad_result", "jenkinsapi_tests/unittests/test_requester.py::test_get_and_confirm_status", "jenkinsapi_tests/unittests/test_requester.py::test_get_and_confirm_status_bad_result" ]
{ "failed_lite_validators": [ "has_hyperlinks" ], "has_test_patch": true, "is_lite": false }
2018-12-27 00:02:31+00:00
mit
4,723
pydantic__pydantic-1034
diff --git a/docs/examples/models_signature.py b/docs/examples/models_signature.py new file mode 100644 --- /dev/null +++ b/docs/examples/models_signature.py @@ -0,0 +1,10 @@ +import inspect +from pydantic import BaseModel, Field + +class FooModel(BaseModel): + id: int + name: str = None + description: str = 'Foo' + apple: int = Field(..., alias='pear') + +print(inspect.signature(FooModel)) diff --git a/docs/examples/models_signature_custom_init.py b/docs/examples/models_signature_custom_init.py new file mode 100644 --- /dev/null +++ b/docs/examples/models_signature_custom_init.py @@ -0,0 +1,13 @@ +import inspect + +from pydantic import BaseModel + +class MyModel(BaseModel): + id: int + info: str = 'Foo' + + def __init__(self, id: int = 1, *, bar: str, **data) -> None: + """My custom init!""" + super().__init__(id=id, bar=bar, **data) + +print(inspect.signature(MyModel)) diff --git a/pydantic/main.py b/pydantic/main.py --- a/pydantic/main.py +++ b/pydantic/main.py @@ -18,9 +18,18 @@ from .schema import model_schema from .types import PyObject, StrBytes from .typing import AnyCallable, AnyType, ForwardRef, is_classvar, resolve_annotations, update_field_forward_refs -from .utils import GetterDict, Representation, ValueItems, lenient_issubclass, sequence_like, validate_field_name +from .utils import ( + GetterDict, + Representation, + ValueItems, + generate_model_signature, + lenient_issubclass, + sequence_like, + validate_field_name, +) if TYPE_CHECKING: + from inspect import Signature from .class_validators import ValidatorListDict from .types import ModelOrDc from .typing import CallableGenerator, TupleGenerator, DictStrAny, DictAny, SetStr @@ -156,6 +165,8 @@ def __new__(mcs, name, bases, namespace, **kwargs): # noqa C901 fields: Dict[str, ModelField] = {} config = BaseConfig validators: 'ValidatorListDict' = {} + fields_defaults: Dict[str, Any] = {} + pre_root_validators, post_root_validators = [], [] for base in reversed(bases): if issubclass(base, BaseModel) and base != BaseModel: @@ -170,6 +181,9 @@ def __new__(mcs, name, bases, namespace, **kwargs): # noqa C901 vg = ValidatorGroup(validators) for f in fields.values(): + if not f.required: + fields_defaults[f.name] = f.default + f.set_config(config) extra_validators = vg.get_validators(f.name) if extra_validators: @@ -196,13 +210,15 @@ def __new__(mcs, name, bases, namespace, **kwargs): # noqa C901 and not lenient_issubclass(getattr(ann_type, '__origin__', None), Type) ): continue - fields[ann_name] = ModelField.infer( + fields[ann_name] = inferred = ModelField.infer( name=ann_name, value=value, annotation=ann_type, class_validators=vg.get_validators(ann_name), config=config, ) + if not inferred.required: + fields_defaults[ann_name] = inferred.default for var_name, value in namespace.items(): if ( @@ -225,6 +241,8 @@ def __new__(mcs, name, bases, namespace, **kwargs): # noqa C901 f'if you wish to change the type of this field, please use a type annotation' ) fields[var_name] = inferred + if not inferred.required: + fields_defaults[var_name] = inferred.default _custom_root_type = ROOT_KEY in fields if _custom_root_type: @@ -238,7 +256,7 @@ def __new__(mcs, name, bases, namespace, **kwargs): # noqa C901 new_namespace = { '__config__': config, '__fields__': fields, - '__field_defaults__': {n: f.default for n, f in fields.items() if not f.required}, + '__field_defaults__': fields_defaults, '__validators__': vg.validators, '__pre_root_validators__': pre_root_validators + pre_rv_new, '__post_root_validators__': post_root_validators + post_rv_new, @@ -247,7 +265,10 @@ def __new__(mcs, name, bases, namespace, **kwargs): # noqa C901 '__custom_root_type__': _custom_root_type, **{n: v for n, v in namespace.items() if n not in fields}, } - return super().__new__(mcs, name, bases, new_namespace, **kwargs) + + cls = super().__new__(mcs, name, bases, new_namespace, **kwargs) + cls.__signature__ = generate_model_signature(cls.__init__, fields, config) + return cls class BaseModel(metaclass=ModelMetaclass): @@ -263,6 +284,7 @@ class BaseModel(metaclass=ModelMetaclass): __json_encoder__: Callable[[Any], Any] = lambda x: x __schema_cache__: 'DictAny' = {} __custom_root_type__: bool = False + __signature__: 'Signature' Config = BaseConfig __slots__ = ('__dict__', '__fields_set__') @@ -274,6 +296,11 @@ class BaseModel(metaclass=ModelMetaclass): __repr__ = Representation.__repr__ def __init__(__pydantic_self__, **data: Any) -> None: + """ + Create a new model by parsing and validating input data from keyword arguments. + + Raises ValidationError if the input data cannot be parsed to form a valid model. + """ # Uses something other than `self` the first arg to allow "self" as a settable attribute if TYPE_CHECKING: __pydantic_self__.__dict__: Dict[str, Any] = {} diff --git a/pydantic/utils.py b/pydantic/utils.py --- a/pydantic/utils.py +++ b/pydantic/utils.py @@ -1,4 +1,5 @@ import warnings +from itertools import islice from types import GeneratorType from typing import ( TYPE_CHECKING, @@ -22,8 +23,10 @@ from .version import version_info if TYPE_CHECKING: - from .main import BaseModel # noqa: F401 + from inspect import Signature + from .main import BaseModel, BaseConfig # noqa: F401 from .typing import AbstractSetIntStr, DictIntStrAny, IntStr, ReprArgs # noqa: F401 + from .fields import ModelField # noqa: F401 from .dataclasses import DataclassType # noqa: F401 __all__ = ( @@ -136,6 +139,51 @@ def almost_equal_floats(value_1: float, value_2: float, *, delta: float = 1e-8) return abs(value_1 - value_2) <= delta +def generate_model_signature( + init: Callable[..., None], fields: Dict[str, 'ModelField'], config: Type['BaseConfig'] +) -> 'Signature': + """ + Generate signature for model based on its fields + """ + from inspect import Parameter, Signature, signature + + present_params = signature(init).parameters.values() + merged_params: Dict[str, Parameter] = {} + var_kw = None + use_var_kw = False + + for param in islice(present_params, 1, None): # skip self arg + if param.kind is param.VAR_KEYWORD: + var_kw = param + continue + merged_params[param.name] = param + + if var_kw: # if custom init has no var_kw, fields which are not declared in it cannot be passed through + allow_names = config.allow_population_by_field_name + for field_name, field in fields.items(): + param_name = field.alias + if field_name in merged_params or param_name in merged_params: + continue + elif not param_name.isidentifier(): + if allow_names and field_name.isidentifier(): + param_name = field_name + else: + use_var_kw = True + continue + + # TODO: replace annotation with actual expected types once #1055 solved + kwargs = {'default': field.default} if not field.required else {} + merged_params[param_name] = Parameter(param_name, Parameter.KEYWORD_ONLY, annotation=field.type_, **kwargs) + + if config.extra is config.extra.allow: + use_var_kw = True + + if var_kw and use_var_kw: + merged_params[var_kw.name] = var_kw + + return Signature(parameters=list(merged_params.values()), return_annotation=None) + + def get_model(obj: Union[Type['BaseModel'], Type['DataclassType']]) -> Type['BaseModel']: from .main import BaseModel # noqa: F811
pydantic/pydantic
a97c120dbf5e5c937800622dd330cb7c386d006c
Your approach sounds very good to me, PR welcome. Questions: * I assume this would not impact performance. Am I right? * Are there any situations where this could cause problems or backwards incompatibility? E.g. do we need to wait for v2? I assume not. * Are there any other places where this could help? E.g. ipython maybe? Presumably not pycharm, vscode or vim? Would it work to just set the `__signature__` attribute of the model `__init__`? This is enough to work with `inspect.signature`, which is used, for example, by FastAPI; I'm not sure how it relates to the other tools discussed above. If you just need to update `__signature__`, I have a variety of examples doing this for various fastapi-related purposes that may be useful for reference. See, for example, here: https://gist.github.com/dmontagu/87e9d3d7795b14b63388d4b16054f0ff#file-fastapi_cbv-py-L37-L47 Also, I have worked through most of the config-related logic for what the generated signature should look like in the mypy plugin. So that might provide a good reference, e.g., if `Config.allow_extra` is `False` or similar, and you want to be really careful. > I assume this would not impact performance. Am I right? This has relatively small impact only on model creation. > Are there any situations where this could cause problems or backwards incompatibility? E.g. do we need to wait for v2? I assume not. If we implement this right (e. g. respect `__code__` differences between python versions), no, I don't think so. ### Question to think about: What if subclass of a model declares `__init__`? Would we merge it's signature, rewrite it or leave as is? ```py class MyModel(BaseModel): id: int name: str = 'John' def __init__(self, foo: int = 41, **data): self.foo = foo + 1 return super().__init__(**data) ``` > Would it work to just set the `__signature__` attribute of the model `__init__`? This is enough to work with `inspect.signature`, which is used, for example, by FastAPI; I'm not sure how it relates to the other tools discussed above. @dmontagu , just to be clear, do you suggest construct new signature from scratch and set it to `__init__`, or generate function and copy its signature to `__init__`? Generate a new signature from scratch; it's not too hard using the objects from the `inspect` module. Sounds good. Having `__signature__` is enough for FastAPI to understand right parameters. However, I'm not sure if it's gonna work everywhere, as `__signature__` is not present in function type by default and used only in `inspect` module. I think the best is to have all: valid `__wrapped__`, `__kwdefaults__`, `__annotations__` and `__signature__` together to make sure any kind of inspection will work properly. Oh, looks like there's case when we can't use `__signature__`: ```py if not name.isidentifier(): > raise ValueError('{!r} is not a valid parameter name'.format(name)) E ValueError: 'this-is-funky' is not a valid parameter name ``` @MrMrRobat I think `this-is-funky` is an invalid signature name. Is there a case to give a method an invalid name? If I misread it, sorry. I'm assuming this is coming from an alias? Yeah, I'm generally against giving methods signatures based on aliases. In general, aliases don't seem to play super nicely with existing python tools, a reason I heavily prefer having `allow_population_by_alias=True`. I think part of the problem is that `__init__` is used for *both* parsing, where JSON schema conventions are important, *and* initializing in non-parsing contexts, where python conventions are important (e.g., for type checking, auto-docs-generation, IDEs, etc.). The `construct` method mitigates this to some extent, but I think there is still some awkwardness, e.g., if you need your validators to run on the inputs. I think I personally would prefer if `__init__` always expected non-aliases, and aliases were only relevant for the `parse` methods. (But I recognize obviously that's a huge breaking change from how things work now, so will probably never happen, and others may not feel the same way I do on this point anyway 😅.) > I think `this-is-funky` is an invalid signature name. > Is there a case to give a method an invalid name? Not a method, but field. >I'm assuming this is coming from an alias? In comes from test_create_model: https://github.com/samuelcolvin/pydantic/blob/c71326d4a6898612597d3c647a4256f168818e30/tests/test_create_model.py#L127-L136 @MrMrRobat We should ignore an invalid field name to create `__signature__` when using `create_model()` with an invalid name. Also, Someone may want to add valid field to `__sigunature___` on Model which is created by `create_model()` ```python model = create_model('FooModel', **{'this-is-funky': (int, 1), 'bar': (int, ...)}) m = model(**{'this-is-funky': '123', 'bar': '456'}) assert m.dict() == {'this-is-funky': 123, 'bar': 456} print(inspect.signature(model)) # > (**data: Any) -> None print(model(bar='789')) # > FooModel this-is-funky=1 bar=789 ```
diff --git a/tests/test_model_signature.py b/tests/test_model_signature.py new file mode 100644 --- /dev/null +++ b/tests/test_model_signature.py @@ -0,0 +1,74 @@ +from inspect import signature +from typing import Any, Iterable, Union + +from pydantic import BaseModel, Extra, Field, create_model + + +def _equals(a: Union[str, Iterable[str]], b: Union[str, Iterable[str]]) -> bool: + """ + compare strings with spaces removed + """ + if isinstance(a, str) and isinstance(b, str): + return a.replace(' ', '') == b.replace(' ', '') + elif isinstance(a, Iterable) and isinstance(b, Iterable): + return all(_equals(a_, b_) for a_, b_ in zip(a, b)) + else: + raise TypeError(f'arguments must be both strings or both lists, not {type(a)}, {type(b)}') + + +def test_model_signature(): + class Model(BaseModel): + a: float = Field(..., title='A') + b = Field(10) + + sig = signature(Model) + assert sig != signature(BaseModel) + assert _equals(map(str, sig.parameters.values()), ('a: float', 'b: int = 10')) + assert _equals(str(sig), '(*, a: float, b: int = 10) -> None') + + +def test_custom_init_signature(): + class MyModel(BaseModel): + id: int + name: str = 'John Doe' + f__: str = Field(..., alias='foo') + + class Config: + extra = Extra.allow + + def __init__(self, id: int = 1, bar=2, *, baz: Any, **data): + super().__init__(id=id, **data) + self.bar = bar + self.baz = baz + + sig = signature(MyModel) + assert _equals( + map(str, sig.parameters.values()), + ('id: int = 1', 'bar=2', 'baz: Any', "name: str = 'John Doe'", 'foo: str', '**data'), + ) + + assert _equals(str(sig), "(id: int = 1, bar=2, *, baz: Any, name: str = 'John Doe', foo: str, **data) -> None") + + +def test_custom_init_signature_with_no_var_kw(): + class Model(BaseModel): + a: float + b: int = 2 + c: int + + def __init__(self, a: float, b: int): + super().__init__(a=a, b=b, c=1) + + class Config: + extra = Extra.allow + + assert _equals(str(signature(Model)), '(a: float, b: int) -> None') + + +def test_invalid_identifiers_signature(): + model = create_model( + 'Model', **{'123 invalid identifier!': Field(123, alias='valid_identifier'), '!': Field(0, alias='yeah')} + ) + assert _equals(str(signature(model)), '(*, valid_identifier: int = 123, yeah: int = 0) -> None') + model = create_model('Model', **{'123 invalid identifier!': 123, '!': Field(0, alias='yeah')}) + assert _equals(str(signature(model)), '(*, yeah: int = 0, **data: Any) -> None')
Generate actual signature for BaseModel.__init__ # Feature Request That idea came for me when I saw this issue: https://github.com/tiangolo/fastapi/issues/318 And this particular comment that shows that standart inspect tools unable to determine signature of a pydantic model: > @tiangolo, I had an opportunity to fiddle a little bit more with this today. > Here is a full example of the different ways to specify parameters using depends: https://gist.github.com/Atheuz/075f4d8fe3b56d034741301ba2574ef1 > > You can run it using this command `uvicorn run:app --reload --host 0.0.0.0 --port 8080` > > I essence: dataclass classes work if I specify `Query(None)` and `Depends`, pure classes work if I specify `Query(None)` and use `Depends`, and input parameters in the signature just works. > > Pydantic classes do not work, at least in terms of the generated docs, it just says `data` instead of the expected `dt` and `to_sum`. > > dataclasses in the generated docs: > ![billede](https://user-images.githubusercontent.com/202696/59960977-0c7b6580-94d1-11e9-95ad-c89090f133f9.png) > > pydantic in the generated docs: > ![billede](https://user-images.githubusercontent.com/202696/59960978-18ffbe00-94d1-11e9-9869-524c738cd0e2.png) This, however is not true for dataclasses, where `__init__` is generated on class creation. ```py @dataclass class Dataclass: id: int name: str = 'John' class Model(BaseModel): id: int name: str = 'John' help(Dataclass.__init__) ''' Help on function __init__: __init__(self, id: int, name: str = 'John') -> None ''' help(Model.__init__) ''' Help on function __init__ in module pydantic.main: __init__(__pydantic_self__, **data: Any) -> None Initialize self. See help(type(self)) for accurate signature. ''' ``` Of course, we cannot follow dataclasses in this part and generate `__init__` of `BaseModel`, since it will cause getting `TypeError` instead of `ValidationError` on missing values, etc., but we still can help inspect tools to see the right signature of our models. ```py from functools import update_wrapper import pydantic def __init__(self, *, id: int, name: str = 'John') -> None: ... update_wrapper(Model.__init__, __init__) help(Model.__init__) ''' Help on function __init__ in module __main__: __init__(self, *, id: int, name: str = 'John') -> None ''' ``` # Possible approaches I see this ways of creating typed `__init__`: - Generate it as a string and use `eval()` - Create function normally and modify its __code__ signature and then use `functools.update_wrapper(Model.__init__, typed_func)` # Example ```py # using `Model` declared above def f(): ... f.__code__ = f.__code__.replace( # __code__.replace() available only in python >= 3.8 co_kwonlyargcount=len(Model.__fields__), co_argcount=1, co_varnames=('__pydantic_self__',) + tuple(Model.__fields__) ) defaults, annotations = {}, {} for name, field in Model.__fields__.items(): if field.default: defaults[name] = field.default annotations[name] = field.type_ f.__kwdefaults__ = defaults f.__annotations__ = annotations help(f) ''' Help on function f in module __main__: f(__pydantic_self__, *, id: int, name: str = 'John') ''' ```
0.0
a97c120dbf5e5c937800622dd330cb7c386d006c
[ "tests/test_model_signature.py::test_model_signature", "tests/test_model_signature.py::test_custom_init_signature", "tests/test_model_signature.py::test_custom_init_signature_with_no_var_kw", "tests/test_model_signature.py::test_invalid_identifiers_signature" ]
[]
{ "failed_lite_validators": [ "has_hyperlinks", "has_media", "has_added_files", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2019-11-26 10:58:43+00:00
mit
4,724
pydantic__pydantic-1045
diff --git a/pydantic/schema.py b/pydantic/schema.py --- a/pydantic/schema.py +++ b/pydantic/schema.py @@ -72,16 +72,17 @@ literal_values, new_type_supertype, ) -from .utils import lenient_issubclass +from .utils import get_model, lenient_issubclass if TYPE_CHECKING: from .main import BaseModel # noqa: F401 + from .dataclasses import DataclassType # noqa: F401 default_prefix = '#/definitions/' def schema( - models: Sequence[Type['BaseModel']], + models: Sequence[Union[Type['BaseModel'], Type['DataclassType']]], *, by_alias: bool = True, title: Optional[str] = None, @@ -104,8 +105,9 @@ def schema( :return: dict with the JSON Schema with a ``definitions`` top-level key including the schema definitions for the models and sub-models passed in ``models``. """ + clean_models = [get_model(model) for model in models] ref_prefix = ref_prefix or default_prefix - flat_models = get_flat_models_from_models(models) + flat_models = get_flat_models_from_models(clean_models) model_name_map = get_model_name_map(flat_models) definitions = {} output_schema: Dict[str, Any] = {} @@ -113,7 +115,7 @@ def schema( output_schema['title'] = title if description: output_schema['description'] = description - for model in models: + for model in clean_models: m_schema, m_definitions, m_nested_models = model_process_schema( model, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix ) @@ -125,7 +127,9 @@ def schema( return output_schema -def model_schema(model: Type['BaseModel'], by_alias: bool = True, ref_prefix: Optional[str] = None) -> Dict[str, Any]: +def model_schema( + model: Union[Type['BaseModel'], Type['DataclassType']], by_alias: bool = True, ref_prefix: Optional[str] = None +) -> Dict[str, Any]: """ Generate a JSON Schema for one model. With all the sub-models defined in the ``definitions`` top-level JSON key. @@ -139,6 +143,7 @@ def model_schema(model: Type['BaseModel'], by_alias: bool = True, ref_prefix: Op prefix. :return: dict with the JSON Schema for the passed ``model`` """ + model = get_model(model) ref_prefix = ref_prefix or default_prefix flat_models = get_flat_models_from_model(model) model_name_map = get_model_name_map(flat_models) diff --git a/pydantic/utils.py b/pydantic/utils.py --- a/pydantic/utils.py +++ b/pydantic/utils.py @@ -24,6 +24,7 @@ if TYPE_CHECKING: from .main import BaseModel # noqa: F401 from .typing import AbstractSetIntStr, DictIntStrAny, IntStr, ReprArgs # noqa: F401 + from .dataclasses import DataclassType # noqa: F401 KeyType = TypeVar('KeyType') @@ -114,6 +115,19 @@ def almost_equal_floats(value_1: float, value_2: float, *, delta: float = 1e-8) return abs(value_1 - value_2) <= delta +def get_model(obj: Union[Type['BaseModel'], Type['DataclassType']]) -> Type['BaseModel']: + from .main import BaseModel # noqa: F811 + + try: + model_cls = obj.__pydantic_model__ # type: ignore + except AttributeError: + model_cls = obj + + if not issubclass(model_cls, BaseModel): + raise TypeError('Unsupported type, must be either BaseModel or dataclass') + return model_cls + + class PyObjectStr(str): """ String class where repr doesn't include quotes. Useful with Representation when you want to return a string
pydantic/pydantic
151143deb4eaf6a5e2dce4532659e5ee9e2e4713
That's not how the `schema` function is designed to work. Did you find somewhere in the docs that suggested that? For now the solution is to use `Model.__pydantic_model__.schema()`, if you'd like to modify `schema()` to accept a dataclass, please submit a PR. > That's not how the schema function is designed to work. Did you find somewhere in the docs that suggested that? Ah, apologies, I must've misunderstood. I mostly just expected dataclasses to work similarly to things that inherit from `BaseModel` and don't think I read that `schema()` supports them. I'd like to make a PR but honestly I'm not sure when I will have the time, so feel free to close if you want. no problem. Would definitely be better if `schema()` worked with dataclasses as it does with models, so I'll leave this open and fix it when I get a chance if no one else does before.
diff --git a/tests/test_schema.py b/tests/test_schema.py --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -13,6 +13,7 @@ from pydantic import BaseModel, Extra, Field, ValidationError, conlist, validator from pydantic.color import Color +from pydantic.dataclasses import dataclass from pydantic.networks import AnyUrl, EmailStr, IPvAnyAddress, IPvAnyInterface, IPvAnyNetwork, NameEmail, stricturl from pydantic.schema import ( get_flat_models_from_model, @@ -1639,3 +1640,27 @@ class MyModel(BaseModel): }, 'required': ['entries'], } + + +def test_dataclass(): + @dataclass + class Model: + a: bool + + assert schema([Model]) == { + 'definitions': { + 'Model': { + 'title': 'Model', + 'type': 'object', + 'properties': {'a': {'title': 'A', 'type': 'boolean'}}, + 'required': ['a'], + } + } + } + + assert model_schema(Model) == { + 'title': 'Model', + 'type': 'object', + 'properties': {'a': {'title': 'A', 'type': 'boolean'}}, + 'required': ['a'], + } diff --git a/tests/test_utils.py b/tests/test_utils.py --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -7,9 +7,10 @@ from pydantic import BaseModel from pydantic.color import Color +from pydantic.dataclasses import dataclass from pydantic.fields import Undefined from pydantic.typing import display_as_type, is_new_type, new_type_supertype -from pydantic.utils import ValueItems, deep_update, import_string, lenient_issubclass, truncate +from pydantic.utils import ValueItems, deep_update, get_model, import_string, lenient_issubclass, truncate try: import devtools @@ -265,3 +266,22 @@ def test_deep_update_is_not_mutating(): def test_undefined_repr(): assert repr(Undefined) == 'PydanticUndefined' + + +def test_get_model(): + class A(BaseModel): + a: str + + assert get_model(A) == A + + @dataclass + class B: + a: str + + assert get_model(B) == B.__pydantic_model__ + + class C: + pass + + with pytest.raises(TypeError): + get_model(C)
AttributeError when using dataclass with schema function # Bug Please complete: * OS: macOS * Python version `import sys; print(sys.version)`: 3.7.4 * Pydantic version `import pydantic; print(pydantic.VERSION)`: 0.32.2, as well as master as of 7901711 Where possible please include a self contained code snippet describing your bug: ```py from pydantic.dataclasses import dataclass from pydantic.schema import schema @dataclass class Model: name: str schema([Model]) ``` This produces an error message like: ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/jamie/.virtualenvs/tempenv-74cd74727d61/lib/python3.7/site-packages/pydantic/schema.py", line 185, in schema flat_models = get_flat_models_from_models(models) File "/Users/jamie/.virtualenvs/tempenv-74cd74727d61/lib/python3.7/site-packages/pydantic/schema.py", line 437, in get_flat_models_from_models flat_models |= get_flat_models_from_model(model) File "/Users/jamie/.virtualenvs/tempenv-74cd74727d61/lib/python3.7/site-packages/pydantic/schema.py", line 378, in get_flat_models_from_model fields = cast(Sequence[Field], model.__fields__.values()) AttributeError: type object 'Model' has no attribute '__fields__' ``` The same code using `BaseModel` instead of the `@dataclass` works fine. With the `dataclass`, `Model.__pydantic_model__.schema()` also works.
0.0
151143deb4eaf6a5e2dce4532659e5ee9e2e4713
[ "tests/test_schema.py::test_key", "tests/test_schema.py::test_by_alias", "tests/test_schema.py::test_sub_model", "tests/test_schema.py::test_schema_class", "tests/test_schema.py::test_schema_repr", "tests/test_schema.py::test_schema_class_by_alias", "tests/test_schema.py::test_choices", "tests/test_schema.py::test_json_schema", "tests/test_schema.py::test_list_sub_model", "tests/test_schema.py::test_optional", "tests/test_schema.py::test_any", "tests/test_schema.py::test_set", "tests/test_schema.py::test_const_str", "tests/test_schema.py::test_const_false", "tests/test_schema.py::test_tuple[tuple-expected_schema0]", "tests/test_schema.py::test_tuple[field_type1-expected_schema1]", "tests/test_schema.py::test_tuple[field_type2-expected_schema2]", "tests/test_schema.py::test_bool", "tests/test_schema.py::test_strict_bool", "tests/test_schema.py::test_dict", "tests/test_schema.py::test_list", "tests/test_schema.py::test_list_union_dict[field_type0-expected_schema0]", "tests/test_schema.py::test_list_union_dict[field_type1-expected_schema1]", "tests/test_schema.py::test_list_union_dict[field_type2-expected_schema2]", "tests/test_schema.py::test_list_union_dict[field_type3-expected_schema3]", "tests/test_schema.py::test_list_union_dict[field_type4-expected_schema4]", "tests/test_schema.py::test_date_types[datetime-expected_schema0]", "tests/test_schema.py::test_date_types[date-expected_schema1]", "tests/test_schema.py::test_date_types[time-expected_schema2]", "tests/test_schema.py::test_date_types[timedelta-expected_schema3]", "tests/test_schema.py::test_str_basic_types[field_type0-expected_schema0]", "tests/test_schema.py::test_str_basic_types[field_type1-expected_schema1]", "tests/test_schema.py::test_str_basic_types[field_type2-expected_schema2]", "tests/test_schema.py::test_str_basic_types[field_type3-expected_schema3]", "tests/test_schema.py::test_str_constrained_types[StrictStr-expected_schema0]", "tests/test_schema.py::test_str_constrained_types[ConstrainedStr-expected_schema1]", "tests/test_schema.py::test_str_constrained_types[ConstrainedStrValue-expected_schema2]", "tests/test_schema.py::test_special_str_types[AnyUrl-expected_schema0]", "tests/test_schema.py::test_special_str_types[UrlValue-expected_schema1]", "tests/test_schema.py::test_email_str_types[EmailStr-email]", "tests/test_schema.py::test_email_str_types[NameEmail-name-email]", "tests/test_schema.py::test_secret_types[SecretBytes-string]", "tests/test_schema.py::test_secret_types[SecretStr-string]", "tests/test_schema.py::test_special_int_types[ConstrainedInt-expected_schema0]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema1]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema2]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema3]", "tests/test_schema.py::test_special_int_types[PositiveInt-expected_schema4]", "tests/test_schema.py::test_special_int_types[NegativeInt-expected_schema5]", "tests/test_schema.py::test_special_float_types[ConstrainedFloat-expected_schema0]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema1]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema2]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema3]", "tests/test_schema.py::test_special_float_types[PositiveFloat-expected_schema4]", "tests/test_schema.py::test_special_float_types[NegativeFloat-expected_schema5]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimal-expected_schema6]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema7]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema8]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema9]", "tests/test_schema.py::test_uuid_types[UUID-uuid]", "tests/test_schema.py::test_uuid_types[UUID1-uuid1]", "tests/test_schema.py::test_uuid_types[UUID3-uuid3]", "tests/test_schema.py::test_uuid_types[UUID4-uuid4]", "tests/test_schema.py::test_uuid_types[UUID5-uuid5]", "tests/test_schema.py::test_path_types[FilePath-file-path]", "tests/test_schema.py::test_path_types[DirectoryPath-directory-path]", "tests/test_schema.py::test_path_types[Path-path]", "tests/test_schema.py::test_json_type", "tests/test_schema.py::test_ipv4address_type", "tests/test_schema.py::test_ipv6address_type", "tests/test_schema.py::test_ipvanyaddress_type", "tests/test_schema.py::test_ipv4interface_type", "tests/test_schema.py::test_ipv6interface_type", "tests/test_schema.py::test_ipvanyinterface_type", "tests/test_schema.py::test_ipv4network_type", "tests/test_schema.py::test_ipv6network_type", "tests/test_schema.py::test_ipvanynetwork_type", "tests/test_schema.py::test_callable_type[annotation0]", "tests/test_schema.py::test_callable_type[annotation1]", "tests/test_schema.py::test_error_non_supported_types", "tests/test_schema.py::test_flat_models_unique_models", "tests/test_schema.py::test_flat_models_with_submodels", "tests/test_schema.py::test_flat_models_with_submodels_from_sequence", "tests/test_schema.py::test_model_name_maps", "tests/test_schema.py::test_schema_overrides", "tests/test_schema.py::test_schema_from_models", "tests/test_schema.py::test_schema_with_ref_prefix", "tests/test_schema.py::test_schema_no_definitions", "tests/test_schema.py::test_list_default", "tests/test_schema.py::test_dict_default", "tests/test_schema.py::test_constraints_schema[kwargs0-str-expected_extra0]", "tests/test_schema.py::test_constraints_schema[kwargs1-ConstrainedStrValue-expected_extra1]", "tests/test_schema.py::test_constraints_schema[kwargs2-str-expected_extra2]", "tests/test_schema.py::test_constraints_schema[kwargs3-bytes-expected_extra3]", "tests/test_schema.py::test_constraints_schema[kwargs4-str-expected_extra4]", "tests/test_schema.py::test_constraints_schema[kwargs5-int-expected_extra5]", "tests/test_schema.py::test_constraints_schema[kwargs6-int-expected_extra6]", "tests/test_schema.py::test_constraints_schema[kwargs7-int-expected_extra7]", "tests/test_schema.py::test_constraints_schema[kwargs8-int-expected_extra8]", "tests/test_schema.py::test_constraints_schema[kwargs9-int-expected_extra9]", "tests/test_schema.py::test_constraints_schema[kwargs10-float-expected_extra10]", "tests/test_schema.py::test_constraints_schema[kwargs11-float-expected_extra11]", "tests/test_schema.py::test_constraints_schema[kwargs12-float-expected_extra12]", "tests/test_schema.py::test_constraints_schema[kwargs13-float-expected_extra13]", "tests/test_schema.py::test_constraints_schema[kwargs14-float-expected_extra14]", "tests/test_schema.py::test_constraints_schema[kwargs15-Decimal-expected_extra15]", "tests/test_schema.py::test_constraints_schema[kwargs16-Decimal-expected_extra16]", "tests/test_schema.py::test_constraints_schema[kwargs17-Decimal-expected_extra17]", "tests/test_schema.py::test_constraints_schema[kwargs18-Decimal-expected_extra18]", "tests/test_schema.py::test_constraints_schema[kwargs19-Decimal-expected_extra19]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs0-int]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs1-float]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs2-Decimal]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs3-int]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs4-str]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs5-bytes]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs6-str]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs7-bool]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs9-type_9]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs10-ConstrainedListValue]", "tests/test_schema.py::test_constraints_schema_validation[kwargs0-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs1-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs2-bytes-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs3-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs4-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs5-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs6-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs7-int-2]", "tests/test_schema.py::test_constraints_schema_validation[kwargs8-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs9-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs10-int-5]", "tests/test_schema.py::test_constraints_schema_validation[kwargs11-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs12-float-2.1]", "tests/test_schema.py::test_constraints_schema_validation[kwargs13-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs14-float-4.9]", "tests/test_schema.py::test_constraints_schema_validation[kwargs15-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs16-float-2.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs17-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs18-float-5.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs19-float-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs20-float-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs21-Decimal-value21]", "tests/test_schema.py::test_constraints_schema_validation[kwargs22-Decimal-value22]", "tests/test_schema.py::test_constraints_schema_validation[kwargs23-Decimal-value23]", "tests/test_schema.py::test_constraints_schema_validation[kwargs24-Decimal-value24]", "tests/test_schema.py::test_constraints_schema_validation[kwargs25-Decimal-value25]", "tests/test_schema.py::test_constraints_schema_validation[kwargs26-Decimal-value26]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs0-str-foobar]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs1-str-f]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs2-str-bar]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs3-int-2]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs4-int-5]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs5-int-1]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs6-int-6]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs7-float-2.0]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs8-float-5.0]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs9-float-1.9]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs10-float-5.1]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs11-Decimal-value11]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs12-Decimal-value12]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs13-Decimal-value13]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs14-Decimal-value14]", "tests/test_schema.py::test_schema_kwargs", "tests/test_schema.py::test_schema_dict_constr", "tests/test_schema.py::test_bytes_constrained_types[ConstrainedBytes-expected_schema0]", "tests/test_schema.py::test_bytes_constrained_types[ConstrainedBytesValue-expected_schema1]", "tests/test_schema.py::test_optional_dict", "tests/test_schema.py::test_optional_validator", "tests/test_schema.py::test_field_with_validator", "tests/test_schema.py::test_known_model_optimization", "tests/test_schema.py::test_root", "tests/test_schema.py::test_root_list", "tests/test_schema.py::test_root_nested_model", "tests/test_schema.py::test_new_type_schema", "tests/test_schema.py::test_literal_schema", "tests/test_schema.py::test_color_type", "tests/test_schema.py::test_model_with_schema_extra", "tests/test_schema.py::test_model_with_extra_forbidden", "tests/test_schema.py::test_enforced_constraints[int-kwargs0-field_schema0]", "tests/test_schema.py::test_enforced_constraints[annotation1-kwargs1-field_schema1]", "tests/test_schema.py::test_enforced_constraints[annotation2-kwargs2-field_schema2]", "tests/test_schema.py::test_enforced_constraints[annotation3-kwargs3-field_schema3]", "tests/test_schema.py::test_enforced_constraints[annotation4-kwargs4-field_schema4]", "tests/test_schema.py::test_enforced_constraints[annotation5-kwargs5-field_schema5]", "tests/test_schema.py::test_enforced_constraints[annotation6-kwargs6-field_schema6]", "tests/test_schema.py::test_enforced_constraints[annotation7-kwargs7-field_schema7]", "tests/test_schema.py::test_real_vs_phony_constraints", "tests/test_schema.py::test_conlist", "tests/test_schema.py::test_subfield_field_info", "tests/test_schema.py::test_dataclass", "tests/test_utils.py::test_import_module", "tests/test_utils.py::test_import_module_invalid", "tests/test_utils.py::test_import_no_attr", "tests/test_utils.py::test_display_as_type[str-str]", "tests/test_utils.py::test_display_as_type[string-str]", "tests/test_utils.py::test_display_as_type[value2-Union[str,", "tests/test_utils.py::test_display_as_type_enum", "tests/test_utils.py::test_display_as_type_enum_int", "tests/test_utils.py::test_display_as_type_enum_str", "tests/test_utils.py::test_lenient_issubclass", "tests/test_utils.py::test_lenient_issubclass_is_lenient", "tests/test_utils.py::test_truncate[object-<class", "tests/test_utils.py::test_truncate[abcdefghijklmnopqrstuvwxyz-'abcdefghijklmnopq\\u2026']", "tests/test_utils.py::test_truncate[input_value2-[0,", "tests/test_utils.py::test_value_items", "tests/test_utils.py::test_value_items_error", "tests/test_utils.py::test_is_new_type", "tests/test_utils.py::test_new_type_supertype", "tests/test_utils.py::test_pretty", "tests/test_utils.py::test_pretty_color", "tests/test_utils.py::test_devtools_output", "tests/test_utils.py::test_devtools_output_validation_error", "tests/test_utils.py::test_deep_update[mapping0-updating_mapping0-expected_mapping0-extra", "tests/test_utils.py::test_deep_update[mapping1-updating_mapping1-expected_mapping1-values", "tests/test_utils.py::test_deep_update[mapping2-updating_mapping2-expected_mapping2-values", "tests/test_utils.py::test_deep_update[mapping3-updating_mapping3-expected_mapping3-deeply", "tests/test_utils.py::test_deep_update_is_not_mutating", "tests/test_utils.py::test_undefined_repr", "tests/test_utils.py::test_get_model" ]
[]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2019-11-28 21:33:27+00:00
mit
4,725
pydantic__pydantic-1054
diff --git a/docs/build/exec_examples.py b/docs/build/exec_examples.py --- a/docs/build/exec_examples.py +++ b/docs/build/exec_examples.py @@ -91,7 +91,6 @@ def exec_examples(): errors = [] all_md = all_md_contents() new_files = {} - os.environ.clear() os.environ.update({'my_auth_key': 'xxx', 'my_api_key': 'xxx'}) sys.path.append(str(EXAMPLES_DIR)) @@ -113,7 +112,7 @@ def error(desc: str): if f'{{!.tmp_examples/{file.name}!}}' not in all_md: error('file not used anywhere') - file_text = file.read_text() + file_text = file.read_text('utf-8') if '\n\n\n' in file_text: error('too many new lines') if not file_text.endswith('\n'): @@ -184,7 +183,7 @@ def error(desc: str): print(f'writing {len(new_files)} example files to {TMP_EXAMPLES_DIR}') TMP_EXAMPLES_DIR.mkdir() for file_name, content in new_files.items(): - (TMP_EXAMPLES_DIR / file_name).write_text(content) + (TMP_EXAMPLES_DIR / file_name).write_text(content, 'utf-8') gen_ansi_output() return 0 diff --git a/docs/examples/schema_extra_callable.py b/docs/examples/schema_extra_callable.py new file mode 100644 --- /dev/null +++ b/docs/examples/schema_extra_callable.py @@ -0,0 +1,15 @@ +# output-json +from typing import Dict, Any +from pydantic import BaseModel + +class Person(BaseModel): + name: str + age: int + + class Config: + @staticmethod + def schema_extra(schema: Dict[str, Any]) -> None: + for prop in schema.get('properties', {}).values(): + prop.pop('title', None) + +print(Person.schema_json(indent=2)) diff --git a/pydantic/main.py b/pydantic/main.py --- a/pydantic/main.py +++ b/pydantic/main.py @@ -66,7 +66,7 @@ class BaseConfig: getter_dict: Type[GetterDict] = GetterDict alias_generator: Optional[Callable[[str], str]] = None keep_untouched: Tuple[type, ...] = () - schema_extra: Dict[str, Any] = {} + schema_extra: Union[Dict[str, Any], Callable[[Dict[str, Any]], None]] = {} json_loads: Callable[[str], Any] = json.loads json_dumps: Callable[..., str] = json.dumps json_encoders: Dict[AnyType, AnyCallable] = {} diff --git a/pydantic/schema.py b/pydantic/schema.py --- a/pydantic/schema.py +++ b/pydantic/schema.py @@ -466,7 +466,11 @@ def model_process_schema( model, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix, known_models=known_models ) s.update(m_schema) - s.update(model.__config__.schema_extra) + schema_extra = model.__config__.schema_extra + if callable(schema_extra): + schema_extra(s) + else: + s.update(schema_extra) return s, m_definitions, nested_models
pydantic/pydantic
d059fded52cc14fcb4af802034a68ce96fe6ac8a
I don't think we want more config options unless absolutely required. The solution here is to allow `schema_extra` to be a function which can mutate the schema, #889. Happy to accept a PR for that.
diff --git a/tests/test_schema.py b/tests/test_schema.py --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -1482,6 +1482,22 @@ class Config: } +def test_model_with_schema_extra_callable(): + class Model(BaseModel): + name: str = None + + class Config: + @staticmethod + def schema_extra(schema): + schema.pop('properties') + schema['type'] = 'override' + + assert Model.schema() == { + 'title': 'Model', + 'type': 'override', + } + + def test_model_with_extra_forbidden(): class Model(BaseModel): a: str
Supress title generation # Feature Request * OS: **Windows 10** * Python version `import sys; print(sys.version)`: **3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)]** * Pydantic version `import pydantic; print(pydantic.VERSION)`: **1.2** There's no way to suppress/opt-out of the `title` property generation in `schema()`. ```py # main.py import pprint import pydantic class User(pydantic.BaseModel): name: str = pydantic.Field(..., title="", description="User name") password: str = pydantic.Field(..., description="User password") age: int = pydantic.Field(..., title=None, description="User age") pprint.pprint(User.schema()) ``` spits out: ```py {'properties': {'age': {'description': 'User age', 'title': 'Age', 'type': 'integer'}, 'name': {'description': 'User name', 'title': 'Name', 'type': 'string'}, 'password': {'description': 'User password', 'title': 'Password', 'type': 'string'}}, 'required': ['name', 'password', 'age'], 'title': 'User', 'type': 'object'} ``` notice how all `properties` are given the auto-generated `title`. I care about this mostly as a [fastapi](https://github.com/tiangolo/fastapi) user. I don't like how Swagger UI renders the title, and find the title to be redundant with `description` anyway (although maybe I'm missing something?) This can be seen by adding the following to the code above: ```py import fastapi app = fastapi.FastAPI() @app.post("/users") def create_user(user: User): pass ``` and running the server with `uvicorn main:app` (note this will require `pip install fastapi uvicorn`). `http://127.0.0.1:8000/docs` show: ![image](https://user-images.githubusercontent.com/6503002/69888068-dfce4400-12e1-11ea-8c38-ded37bf97f5f.png) If I patch `pydantic/schema.py` with the following: ```py schema_overrides = False # s = dict(title=field.field_info.title or field.alias.title().replace('_', ' ')) s = {} if field.field_info.title: ``` the output is much nicer (IMO): ![image](https://user-images.githubusercontent.com/6503002/69888268-d1ccf300-12e2-11ea-8315-b5cbcf630806.png) I'd be happy to submit a PR. Adding a `Config` option probably makes sense, but maybe there should also be a way to disable the auto-title only for a specific field?
0.0
d059fded52cc14fcb4af802034a68ce96fe6ac8a
[ "tests/test_schema.py::test_model_with_schema_extra_callable" ]
[ "tests/test_schema.py::test_key", "tests/test_schema.py::test_by_alias", "tests/test_schema.py::test_sub_model", "tests/test_schema.py::test_schema_class", "tests/test_schema.py::test_schema_repr", "tests/test_schema.py::test_schema_class_by_alias", "tests/test_schema.py::test_choices", "tests/test_schema.py::test_json_schema", "tests/test_schema.py::test_list_sub_model", "tests/test_schema.py::test_optional", "tests/test_schema.py::test_any", "tests/test_schema.py::test_set", "tests/test_schema.py::test_const_str", "tests/test_schema.py::test_const_false", "tests/test_schema.py::test_tuple[tuple-expected_schema0]", "tests/test_schema.py::test_tuple[field_type1-expected_schema1]", "tests/test_schema.py::test_tuple[field_type2-expected_schema2]", "tests/test_schema.py::test_bool", "tests/test_schema.py::test_strict_bool", "tests/test_schema.py::test_dict", "tests/test_schema.py::test_list", "tests/test_schema.py::test_list_union_dict[field_type0-expected_schema0]", "tests/test_schema.py::test_list_union_dict[field_type1-expected_schema1]", "tests/test_schema.py::test_list_union_dict[field_type2-expected_schema2]", "tests/test_schema.py::test_list_union_dict[field_type3-expected_schema3]", "tests/test_schema.py::test_list_union_dict[field_type4-expected_schema4]", "tests/test_schema.py::test_date_types[datetime-expected_schema0]", "tests/test_schema.py::test_date_types[date-expected_schema1]", "tests/test_schema.py::test_date_types[time-expected_schema2]", "tests/test_schema.py::test_date_types[timedelta-expected_schema3]", "tests/test_schema.py::test_str_basic_types[field_type0-expected_schema0]", "tests/test_schema.py::test_str_basic_types[field_type1-expected_schema1]", "tests/test_schema.py::test_str_basic_types[field_type2-expected_schema2]", "tests/test_schema.py::test_str_basic_types[field_type3-expected_schema3]", "tests/test_schema.py::test_str_constrained_types[StrictStr-expected_schema0]", "tests/test_schema.py::test_str_constrained_types[ConstrainedStr-expected_schema1]", "tests/test_schema.py::test_str_constrained_types[ConstrainedStrValue-expected_schema2]", "tests/test_schema.py::test_special_str_types[AnyUrl-expected_schema0]", "tests/test_schema.py::test_special_str_types[UrlValue-expected_schema1]", "tests/test_schema.py::test_email_str_types[EmailStr-email]", "tests/test_schema.py::test_email_str_types[NameEmail-name-email]", "tests/test_schema.py::test_secret_types[SecretBytes-string]", "tests/test_schema.py::test_secret_types[SecretStr-string]", "tests/test_schema.py::test_special_int_types[ConstrainedInt-expected_schema0]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema1]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema2]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema3]", "tests/test_schema.py::test_special_int_types[PositiveInt-expected_schema4]", "tests/test_schema.py::test_special_int_types[NegativeInt-expected_schema5]", "tests/test_schema.py::test_special_float_types[ConstrainedFloat-expected_schema0]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema1]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema2]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema3]", "tests/test_schema.py::test_special_float_types[PositiveFloat-expected_schema4]", "tests/test_schema.py::test_special_float_types[NegativeFloat-expected_schema5]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimal-expected_schema6]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema7]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema8]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema9]", "tests/test_schema.py::test_uuid_types[UUID-uuid]", "tests/test_schema.py::test_uuid_types[UUID1-uuid1]", "tests/test_schema.py::test_uuid_types[UUID3-uuid3]", "tests/test_schema.py::test_uuid_types[UUID4-uuid4]", "tests/test_schema.py::test_uuid_types[UUID5-uuid5]", "tests/test_schema.py::test_path_types[FilePath-file-path]", "tests/test_schema.py::test_path_types[DirectoryPath-directory-path]", "tests/test_schema.py::test_path_types[Path-path]", "tests/test_schema.py::test_json_type", "tests/test_schema.py::test_ipv4address_type", "tests/test_schema.py::test_ipv6address_type", "tests/test_schema.py::test_ipvanyaddress_type", "tests/test_schema.py::test_ipv4interface_type", "tests/test_schema.py::test_ipv6interface_type", "tests/test_schema.py::test_ipvanyinterface_type", "tests/test_schema.py::test_ipv4network_type", "tests/test_schema.py::test_ipv6network_type", "tests/test_schema.py::test_ipvanynetwork_type", "tests/test_schema.py::test_callable_type[annotation0]", "tests/test_schema.py::test_callable_type[annotation1]", "tests/test_schema.py::test_error_non_supported_types", "tests/test_schema.py::test_flat_models_unique_models", "tests/test_schema.py::test_flat_models_with_submodels", "tests/test_schema.py::test_flat_models_with_submodels_from_sequence", "tests/test_schema.py::test_model_name_maps", "tests/test_schema.py::test_schema_overrides", "tests/test_schema.py::test_schema_from_models", "tests/test_schema.py::test_schema_with_ref_prefix", "tests/test_schema.py::test_schema_no_definitions", "tests/test_schema.py::test_list_default", "tests/test_schema.py::test_dict_default", "tests/test_schema.py::test_constraints_schema[kwargs0-str-expected_extra0]", "tests/test_schema.py::test_constraints_schema[kwargs1-ConstrainedStrValue-expected_extra1]", "tests/test_schema.py::test_constraints_schema[kwargs2-str-expected_extra2]", "tests/test_schema.py::test_constraints_schema[kwargs3-bytes-expected_extra3]", "tests/test_schema.py::test_constraints_schema[kwargs4-str-expected_extra4]", "tests/test_schema.py::test_constraints_schema[kwargs5-int-expected_extra5]", "tests/test_schema.py::test_constraints_schema[kwargs6-int-expected_extra6]", "tests/test_schema.py::test_constraints_schema[kwargs7-int-expected_extra7]", "tests/test_schema.py::test_constraints_schema[kwargs8-int-expected_extra8]", "tests/test_schema.py::test_constraints_schema[kwargs9-int-expected_extra9]", "tests/test_schema.py::test_constraints_schema[kwargs10-float-expected_extra10]", "tests/test_schema.py::test_constraints_schema[kwargs11-float-expected_extra11]", "tests/test_schema.py::test_constraints_schema[kwargs12-float-expected_extra12]", "tests/test_schema.py::test_constraints_schema[kwargs13-float-expected_extra13]", "tests/test_schema.py::test_constraints_schema[kwargs14-float-expected_extra14]", "tests/test_schema.py::test_constraints_schema[kwargs15-Decimal-expected_extra15]", "tests/test_schema.py::test_constraints_schema[kwargs16-Decimal-expected_extra16]", "tests/test_schema.py::test_constraints_schema[kwargs17-Decimal-expected_extra17]", "tests/test_schema.py::test_constraints_schema[kwargs18-Decimal-expected_extra18]", "tests/test_schema.py::test_constraints_schema[kwargs19-Decimal-expected_extra19]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs0-int]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs1-float]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs2-Decimal]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs3-int]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs4-str]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs5-bytes]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs6-str]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs7-bool]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs9-type_9]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs10-ConstrainedListValue]", "tests/test_schema.py::test_constraints_schema_validation[kwargs0-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs1-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs2-bytes-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs3-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs4-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs5-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs6-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs7-int-2]", "tests/test_schema.py::test_constraints_schema_validation[kwargs8-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs9-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs10-int-5]", "tests/test_schema.py::test_constraints_schema_validation[kwargs11-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs12-float-2.1]", "tests/test_schema.py::test_constraints_schema_validation[kwargs13-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs14-float-4.9]", "tests/test_schema.py::test_constraints_schema_validation[kwargs15-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs16-float-2.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs17-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs18-float-5.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs19-float-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs20-float-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs21-Decimal-value21]", "tests/test_schema.py::test_constraints_schema_validation[kwargs22-Decimal-value22]", "tests/test_schema.py::test_constraints_schema_validation[kwargs23-Decimal-value23]", "tests/test_schema.py::test_constraints_schema_validation[kwargs24-Decimal-value24]", "tests/test_schema.py::test_constraints_schema_validation[kwargs25-Decimal-value25]", "tests/test_schema.py::test_constraints_schema_validation[kwargs26-Decimal-value26]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs0-str-foobar]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs1-str-f]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs2-str-bar]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs3-int-2]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs4-int-5]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs5-int-1]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs6-int-6]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs7-float-2.0]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs8-float-5.0]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs9-float-1.9]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs10-float-5.1]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs11-Decimal-value11]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs12-Decimal-value12]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs13-Decimal-value13]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs14-Decimal-value14]", "tests/test_schema.py::test_schema_kwargs", "tests/test_schema.py::test_schema_dict_constr", "tests/test_schema.py::test_bytes_constrained_types[ConstrainedBytes-expected_schema0]", "tests/test_schema.py::test_bytes_constrained_types[ConstrainedBytesValue-expected_schema1]", "tests/test_schema.py::test_optional_dict", "tests/test_schema.py::test_optional_validator", "tests/test_schema.py::test_field_with_validator", "tests/test_schema.py::test_known_model_optimization", "tests/test_schema.py::test_root", "tests/test_schema.py::test_root_list", "tests/test_schema.py::test_root_nested_model", "tests/test_schema.py::test_new_type_schema", "tests/test_schema.py::test_literal_schema", "tests/test_schema.py::test_color_type", "tests/test_schema.py::test_model_with_schema_extra", "tests/test_schema.py::test_model_with_extra_forbidden", "tests/test_schema.py::test_enforced_constraints[int-kwargs0-field_schema0]", "tests/test_schema.py::test_enforced_constraints[annotation1-kwargs1-field_schema1]", "tests/test_schema.py::test_enforced_constraints[annotation2-kwargs2-field_schema2]", "tests/test_schema.py::test_enforced_constraints[annotation3-kwargs3-field_schema3]", "tests/test_schema.py::test_enforced_constraints[annotation4-kwargs4-field_schema4]", "tests/test_schema.py::test_enforced_constraints[annotation5-kwargs5-field_schema5]", "tests/test_schema.py::test_enforced_constraints[annotation6-kwargs6-field_schema6]", "tests/test_schema.py::test_enforced_constraints[annotation7-kwargs7-field_schema7]", "tests/test_schema.py::test_real_vs_phony_constraints", "tests/test_schema.py::test_conlist", "tests/test_schema.py::test_subfield_field_info", "tests/test_schema.py::test_dataclass" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_media", "has_added_files", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2019-11-30 14:59:49+00:00
mit
4,726
pydantic__pydantic-1093
diff --git a/pydantic/env_settings.py b/pydantic/env_settings.py --- a/pydantic/env_settings.py +++ b/pydantic/env_settings.py @@ -66,7 +66,7 @@ class Config: @classmethod def prepare_field(cls, field: ModelField) -> None: env_names: Iterable[str] - env = field.field_info.extra.pop('env', None) + env = field.field_info.extra.get('env') if env is None: if field.has_alias: warnings.warn( diff --git a/pydantic/fields.py b/pydantic/fields.py --- a/pydantic/fields.py +++ b/pydantic/fields.py @@ -280,6 +280,7 @@ def infer( def set_config(self, config: Type['BaseConfig']) -> None: self.model_config = config info_from_config = config.get_field_info(self.name) + config.prepare_field(self) if info_from_config: self.field_info.alias = info_from_config.get('alias') or self.field_info.alias or self.name self.alias = cast(str, self.field_info.alias)
pydantic/pydantic
33fee6d9beaedfac2fd2932d405ba32ae51c0083
I'm looking into this, but I'm afraid the solution isn't trivial. Weird that this got 11 :+1: and 2 :eyes: in 2 hours. Any idea why this happened?
diff --git a/tests/test_settings.py b/tests/test_settings.py --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -376,3 +376,18 @@ class SubSettings(Settings): assert SubSettings().dict() == {'foo': 'fff', 'bar': 'bbb', 'spam': 'spam default'} env.set('spam', 'sss') assert SubSettings().dict() == {'foo': 'fff', 'bar': 'bbb', 'spam': 'sss'} + + +def test_prefix_on_parent(env): + class MyBaseSettings(BaseSettings): + var: str = 'old' + + class MySubSettings(MyBaseSettings): + class Config: + env_prefix = 'PREFIX_' + + assert MyBaseSettings().dict() == {'var': 'old'} + assert MySubSettings().dict() == {'var': 'old'} + env.set('PREFIX_VAR', 'new') + assert MyBaseSettings().dict() == {'var': 'old'} + assert MySubSettings().dict() == {'var': 'new'}
Settings inheritance with ENV prefix does not work # Bug * OS: ubuntu 18.04 * Python version `import sys; print(sys.version)`: 3.7.5 (default, Nov 7 2019, 10:50:52) * Pydantic version `import pydantic; print(pydantic.VERSION)`: `1.0b1` or `1.2`, but works fine with `0.32` ```py import os from pydantic import BaseSettings class MyBaseSettings(BaseSettings): var: int = 10 class MySubSettings(MyBaseSettings): class Config: env_prefix = 'PREFIX_' os.environ['PREFIX_VAR'] = '2' k = MySubSettings() print(k.var) # 10, but should be 2 ``` We expect that `k.var` will be equal to 2, but it has default value 10. It's reproduced since 1.0b1.
0.0
33fee6d9beaedfac2fd2932d405ba32ae51c0083
[ "tests/test_settings.py::test_prefix_on_parent" ]
[ "tests/test_settings.py::test_sub_env", "tests/test_settings.py::test_sub_env_override", "tests/test_settings.py::test_sub_env_missing", "tests/test_settings.py::test_other_setting", "tests/test_settings.py::test_with_prefix", "tests/test_settings.py::test_nested_env_with_basemodel", "tests/test_settings.py::test_nested_env_with_dict", "tests/test_settings.py::test_list", "tests/test_settings.py::test_set_dict_model", "tests/test_settings.py::test_invalid_json", "tests/test_settings.py::test_required_sub_model", "tests/test_settings.py::test_non_class", "tests/test_settings.py::test_env_str", "tests/test_settings.py::test_env_list", "tests/test_settings.py::test_env_list_field", "tests/test_settings.py::test_env_list_last", "tests/test_settings.py::test_env_inheritance", "tests/test_settings.py::test_env_inheritance_field", "tests/test_settings.py::test_env_invalid", "tests/test_settings.py::test_env_field", "tests/test_settings.py::test_aliases_warning", "tests/test_settings.py::test_aliases_no_warning", "tests/test_settings.py::test_case_sensitive", "tests/test_settings.py::test_case_insensitive", "tests/test_settings.py::test_nested_dataclass", "tests/test_settings.py::test_env_takes_precedence", "tests/test_settings.py::test_config_file_settings_nornir", "tests/test_settings.py::test_alias_set" ]
{ "failed_lite_validators": [ "has_many_modified_files" ], "has_test_patch": true, "is_lite": false }
2019-12-09 18:00:40+00:00
mit
4,727
pydantic__pydantic-1125
diff --git a/docs/examples/schema_extra_callable.py b/docs/examples/schema_extra_callable.py --- a/docs/examples/schema_extra_callable.py +++ b/docs/examples/schema_extra_callable.py @@ -1,5 +1,5 @@ # output-json -from typing import Dict, Any +from typing import Dict, Any, Type from pydantic import BaseModel class Person(BaseModel): @@ -8,7 +8,7 @@ class Person(BaseModel): class Config: @staticmethod - def schema_extra(schema: Dict[str, Any]) -> None: + def schema_extra(schema: Dict[str, Any], model: Type['Person']) -> None: for prop in schema.get('properties', {}).values(): prop.pop('title', None) diff --git a/pydantic/schema.py b/pydantic/schema.py --- a/pydantic/schema.py +++ b/pydantic/schema.py @@ -5,6 +5,7 @@ from enum import Enum from ipaddress import IPv4Address, IPv4Interface, IPv4Network, IPv6Address, IPv6Interface, IPv6Network from pathlib import Path +from types import FunctionType from typing import ( TYPE_CHECKING, Any, @@ -450,7 +451,7 @@ def model_process_schema( sub-models of the returned schema will be referenced, but their definitions will not be included in the schema. All the definitions are returned as the second value. """ - from inspect import getdoc + from inspect import getdoc, signature ref_prefix = ref_prefix or default_prefix known_models = known_models or set() @@ -465,7 +466,12 @@ def model_process_schema( s.update(m_schema) schema_extra = model.__config__.schema_extra if callable(schema_extra): - schema_extra(s) + if not isinstance(schema_extra, FunctionType): + raise TypeError(f'{model.__name__}.Config.schema_extra callable is expected to be a staticmethod') + if len(signature(schema_extra).parameters) == 1: + schema_extra(s) + else: + schema_extra(s, model) else: s.update(schema_extra) return s, m_definitions, nested_models
pydantic/pydantic
e169bd60e4e4389e21cde90b01119f62d1b05169
agreed this would be useful, it was an oversight not to add a model argument when we first implemented this. Options: * wait until v2 to add this * add a `model` argument and break `v1.3` - since this was only released yesterday I think we could call it a patch? * inspect `schema_extra` and pass `model` only if the argument is expected. This would be entirely backwards compatible but involve more code Thoughts? I'd say option 2 or 3? Let's do option 2. PR welcome.
diff --git a/tests/test_schema.py b/tests/test_schema.py --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -1490,6 +1490,20 @@ class Config: def test_model_with_schema_extra_callable(): + class Model(BaseModel): + name: str = None + + class Config: + @staticmethod + def schema_extra(schema, model_class): + schema.pop('properties') + schema['type'] = 'override' + assert model_class is Model + + assert Model.schema() == {'title': 'Model', 'type': 'override'} + + +def test_model_with_schema_extra_callable_no_model_class(): class Model(BaseModel): name: str = None @@ -1502,6 +1516,20 @@ def schema_extra(schema): assert Model.schema() == {'title': 'Model', 'type': 'override'} +def test_model_with_schema_extra_callable_classmethod_asserts(): + class Model(BaseModel): + name: str = None + + class Config: + @classmethod + def schema_extra(cls, schema, model_class): + schema.pop('properties') + schema['type'] = 'override' + + with pytest.raises(TypeError, match='Model.Config.schema_extra callable is expected to be a staticmethod'): + Model.schema() + + def test_model_with_extra_forbidden(): class Model(BaseModel): a: str
Support passing model class to schema_extra? # Feature Request As a follow-up to #1054, it would be useful if the model class was passed to the schema_extra callable. I think @dmontagu was thinking along the same lines in this comment: https://github.com/samuelcolvin/pydantic/issues/937#issuecomment-546459285 was there a decision not to implement this or would a PR be accepted? Please complete: * OS: Ubuntu 18.04 * Python version `import sys; print(sys.version)`: 3.7.5 * Pydantic version `import pydantic; print(pydantic.VERSION)`: 1.3 My use case is that I'm adding sub-class configuration in my own nested `Meta` classes, and I'd like to extract information from them in the base class's `schema_extra` ```py from typing import Any, Dict import pydantic class MyBase(pydantic.BaseModel): class Config: @staticmethod def schema_extra(schema: Dict[str, Any], model_class): # ...do something with model_class schema["something"] = model_class.MyMeta.foo class MySubclass(MyBase): class MyMeta: foo = "bar" ``` edit: I originally suggested allowing schema_extra to be a classmethod, but that doesn't work because the cls param would be Config, not the outer model class.
0.0
e169bd60e4e4389e21cde90b01119f62d1b05169
[ "tests/test_schema.py::test_model_with_schema_extra_callable", "tests/test_schema.py::test_model_with_schema_extra_callable_classmethod_asserts" ]
[ "tests/test_schema.py::test_key", "tests/test_schema.py::test_by_alias", "tests/test_schema.py::test_sub_model", "tests/test_schema.py::test_schema_class", "tests/test_schema.py::test_schema_repr", "tests/test_schema.py::test_schema_class_by_alias", "tests/test_schema.py::test_choices", "tests/test_schema.py::test_json_schema", "tests/test_schema.py::test_list_sub_model", "tests/test_schema.py::test_optional", "tests/test_schema.py::test_any", "tests/test_schema.py::test_set", "tests/test_schema.py::test_const_str", "tests/test_schema.py::test_const_false", "tests/test_schema.py::test_tuple[tuple-expected_schema0]", "tests/test_schema.py::test_tuple[field_type1-expected_schema1]", "tests/test_schema.py::test_tuple[field_type2-expected_schema2]", "tests/test_schema.py::test_bool", "tests/test_schema.py::test_strict_bool", "tests/test_schema.py::test_dict", "tests/test_schema.py::test_list", "tests/test_schema.py::test_list_union_dict[field_type0-expected_schema0]", "tests/test_schema.py::test_list_union_dict[field_type1-expected_schema1]", "tests/test_schema.py::test_list_union_dict[field_type2-expected_schema2]", "tests/test_schema.py::test_list_union_dict[field_type3-expected_schema3]", "tests/test_schema.py::test_list_union_dict[field_type4-expected_schema4]", "tests/test_schema.py::test_date_types[datetime-expected_schema0]", "tests/test_schema.py::test_date_types[date-expected_schema1]", "tests/test_schema.py::test_date_types[time-expected_schema2]", "tests/test_schema.py::test_date_types[timedelta-expected_schema3]", "tests/test_schema.py::test_str_basic_types[field_type0-expected_schema0]", "tests/test_schema.py::test_str_basic_types[field_type1-expected_schema1]", "tests/test_schema.py::test_str_basic_types[field_type2-expected_schema2]", "tests/test_schema.py::test_str_basic_types[field_type3-expected_schema3]", "tests/test_schema.py::test_str_constrained_types[StrictStr-expected_schema0]", "tests/test_schema.py::test_str_constrained_types[ConstrainedStr-expected_schema1]", "tests/test_schema.py::test_str_constrained_types[ConstrainedStrValue-expected_schema2]", "tests/test_schema.py::test_special_str_types[AnyUrl-expected_schema0]", "tests/test_schema.py::test_special_str_types[UrlValue-expected_schema1]", "tests/test_schema.py::test_email_str_types[EmailStr-email]", "tests/test_schema.py::test_email_str_types[NameEmail-name-email]", "tests/test_schema.py::test_secret_types[SecretBytes-string]", "tests/test_schema.py::test_secret_types[SecretStr-string]", "tests/test_schema.py::test_special_int_types[ConstrainedInt-expected_schema0]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema1]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema2]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema3]", "tests/test_schema.py::test_special_int_types[PositiveInt-expected_schema4]", "tests/test_schema.py::test_special_int_types[NegativeInt-expected_schema5]", "tests/test_schema.py::test_special_float_types[ConstrainedFloat-expected_schema0]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema1]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema2]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema3]", "tests/test_schema.py::test_special_float_types[PositiveFloat-expected_schema4]", "tests/test_schema.py::test_special_float_types[NegativeFloat-expected_schema5]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimal-expected_schema6]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema7]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema8]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema9]", "tests/test_schema.py::test_uuid_types[UUID-uuid]", "tests/test_schema.py::test_uuid_types[UUID1-uuid1]", "tests/test_schema.py::test_uuid_types[UUID3-uuid3]", "tests/test_schema.py::test_uuid_types[UUID4-uuid4]", "tests/test_schema.py::test_uuid_types[UUID5-uuid5]", "tests/test_schema.py::test_path_types[FilePath-file-path]", "tests/test_schema.py::test_path_types[DirectoryPath-directory-path]", "tests/test_schema.py::test_path_types[Path-path]", "tests/test_schema.py::test_json_type", "tests/test_schema.py::test_ipv4address_type", "tests/test_schema.py::test_ipv6address_type", "tests/test_schema.py::test_ipvanyaddress_type", "tests/test_schema.py::test_ipv4interface_type", "tests/test_schema.py::test_ipv6interface_type", "tests/test_schema.py::test_ipvanyinterface_type", "tests/test_schema.py::test_ipv4network_type", "tests/test_schema.py::test_ipv6network_type", "tests/test_schema.py::test_ipvanynetwork_type", "tests/test_schema.py::test_callable_type[annotation0]", "tests/test_schema.py::test_callable_type[annotation1]", "tests/test_schema.py::test_error_non_supported_types", "tests/test_schema.py::test_flat_models_unique_models", "tests/test_schema.py::test_flat_models_with_submodels", "tests/test_schema.py::test_flat_models_with_submodels_from_sequence", "tests/test_schema.py::test_model_name_maps", "tests/test_schema.py::test_schema_overrides", "tests/test_schema.py::test_schema_from_models", "tests/test_schema.py::test_schema_with_ref_prefix", "tests/test_schema.py::test_schema_no_definitions", "tests/test_schema.py::test_list_default", "tests/test_schema.py::test_dict_default", "tests/test_schema.py::test_constraints_schema[kwargs0-str-expected_extra0]", "tests/test_schema.py::test_constraints_schema[kwargs1-ConstrainedStrValue-expected_extra1]", "tests/test_schema.py::test_constraints_schema[kwargs2-str-expected_extra2]", "tests/test_schema.py::test_constraints_schema[kwargs3-bytes-expected_extra3]", "tests/test_schema.py::test_constraints_schema[kwargs4-str-expected_extra4]", "tests/test_schema.py::test_constraints_schema[kwargs5-int-expected_extra5]", "tests/test_schema.py::test_constraints_schema[kwargs6-int-expected_extra6]", "tests/test_schema.py::test_constraints_schema[kwargs7-int-expected_extra7]", "tests/test_schema.py::test_constraints_schema[kwargs8-int-expected_extra8]", "tests/test_schema.py::test_constraints_schema[kwargs9-int-expected_extra9]", "tests/test_schema.py::test_constraints_schema[kwargs10-float-expected_extra10]", "tests/test_schema.py::test_constraints_schema[kwargs11-float-expected_extra11]", "tests/test_schema.py::test_constraints_schema[kwargs12-float-expected_extra12]", "tests/test_schema.py::test_constraints_schema[kwargs13-float-expected_extra13]", "tests/test_schema.py::test_constraints_schema[kwargs14-float-expected_extra14]", "tests/test_schema.py::test_constraints_schema[kwargs15-Decimal-expected_extra15]", "tests/test_schema.py::test_constraints_schema[kwargs16-Decimal-expected_extra16]", "tests/test_schema.py::test_constraints_schema[kwargs17-Decimal-expected_extra17]", "tests/test_schema.py::test_constraints_schema[kwargs18-Decimal-expected_extra18]", "tests/test_schema.py::test_constraints_schema[kwargs19-Decimal-expected_extra19]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs0-int]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs1-float]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs2-Decimal]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs3-int]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs4-str]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs5-bytes]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs6-str]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs7-bool]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs9-type_9]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs10-ConstrainedListValue]", "tests/test_schema.py::test_constraints_schema_validation[kwargs0-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs1-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs2-bytes-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs3-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs4-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs5-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs6-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs7-int-2]", "tests/test_schema.py::test_constraints_schema_validation[kwargs8-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs9-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs10-int-5]", "tests/test_schema.py::test_constraints_schema_validation[kwargs11-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs12-float-2.1]", "tests/test_schema.py::test_constraints_schema_validation[kwargs13-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs14-float-4.9]", "tests/test_schema.py::test_constraints_schema_validation[kwargs15-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs16-float-2.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs17-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs18-float-5.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs19-float-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs20-float-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs21-Decimal-value21]", "tests/test_schema.py::test_constraints_schema_validation[kwargs22-Decimal-value22]", "tests/test_schema.py::test_constraints_schema_validation[kwargs23-Decimal-value23]", "tests/test_schema.py::test_constraints_schema_validation[kwargs24-Decimal-value24]", "tests/test_schema.py::test_constraints_schema_validation[kwargs25-Decimal-value25]", "tests/test_schema.py::test_constraints_schema_validation[kwargs26-Decimal-value26]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs0-str-foobar]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs1-str-f]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs2-str-bar]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs3-int-2]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs4-int-5]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs5-int-1]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs6-int-6]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs7-float-2.0]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs8-float-5.0]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs9-float-1.9]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs10-float-5.1]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs11-Decimal-value11]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs12-Decimal-value12]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs13-Decimal-value13]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs14-Decimal-value14]", "tests/test_schema.py::test_schema_kwargs", "tests/test_schema.py::test_schema_dict_constr", "tests/test_schema.py::test_bytes_constrained_types[ConstrainedBytes-expected_schema0]", "tests/test_schema.py::test_bytes_constrained_types[ConstrainedBytesValue-expected_schema1]", "tests/test_schema.py::test_optional_dict", "tests/test_schema.py::test_optional_validator", "tests/test_schema.py::test_field_with_validator", "tests/test_schema.py::test_known_model_optimization", "tests/test_schema.py::test_root", "tests/test_schema.py::test_root_list", "tests/test_schema.py::test_root_nested_model", "tests/test_schema.py::test_new_type_schema", "tests/test_schema.py::test_literal_schema", "tests/test_schema.py::test_color_type", "tests/test_schema.py::test_model_with_schema_extra", "tests/test_schema.py::test_model_with_schema_extra_callable_no_model_class", "tests/test_schema.py::test_model_with_extra_forbidden", "tests/test_schema.py::test_enforced_constraints[int-kwargs0-field_schema0]", "tests/test_schema.py::test_enforced_constraints[annotation1-kwargs1-field_schema1]", "tests/test_schema.py::test_enforced_constraints[annotation2-kwargs2-field_schema2]", "tests/test_schema.py::test_enforced_constraints[annotation3-kwargs3-field_schema3]", "tests/test_schema.py::test_enforced_constraints[annotation4-kwargs4-field_schema4]", "tests/test_schema.py::test_enforced_constraints[annotation5-kwargs5-field_schema5]", "tests/test_schema.py::test_enforced_constraints[annotation6-kwargs6-field_schema6]", "tests/test_schema.py::test_enforced_constraints[annotation7-kwargs7-field_schema7]", "tests/test_schema.py::test_real_vs_phony_constraints", "tests/test_schema.py::test_conlist", "tests/test_schema.py::test_subfield_field_info", "tests/test_schema.py::test_dataclass", "tests/test_schema.py::test_schema_attributes", "tests/test_schema.py::test_path_modify_schema", "tests/test_schema.py::test_frozen_set" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks", "has_pytest_match_arg" ], "has_test_patch": true, "is_lite": false }
2019-12-23 21:14:41+00:00
mit
4,728
pydantic__pydantic-1132
diff --git a/pydantic/class_validators.py b/pydantic/class_validators.py --- a/pydantic/class_validators.py +++ b/pydantic/class_validators.py @@ -1,7 +1,6 @@ import warnings from collections import ChainMap from functools import wraps -from inspect import Signature, signature from itertools import chain from types import FunctionType from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Type, Union, overload @@ -32,6 +31,8 @@ def __init__( if TYPE_CHECKING: + from inspect import Signature + from .main import BaseConfig from .fields import ModelField from .types import ModelOrDc @@ -191,6 +192,8 @@ def extract_validators(namespace: Dict[str, Any]) -> Dict[str, List[Validator]]: def extract_root_validators(namespace: Dict[str, Any]) -> Tuple[List[AnyCallable], List[Tuple[bool, AnyCallable]]]: + from inspect import signature + pre_validators: List[AnyCallable] = [] post_validators: List[Tuple[bool, AnyCallable]] = [] for name, value in namespace.items(): @@ -231,6 +234,8 @@ def make_generic_validator(validator: AnyCallable) -> 'ValidatorCallable': It's done like this so validators don't all need **kwargs in their signature, eg. any combination of the arguments "values", "fields" and/or "config" are permitted. """ + from inspect import signature + sig = signature(validator) args = list(sig.parameters.keys()) first_arg = args.pop(0) @@ -254,7 +259,7 @@ def prep_validators(v_funcs: Iterable[AnyCallable]) -> 'ValidatorsList': all_kwargs = {'values', 'field', 'config'} -def _generic_validator_cls(validator: AnyCallable, sig: Signature, args: Set[str]) -> 'ValidatorCallable': +def _generic_validator_cls(validator: AnyCallable, sig: 'Signature', args: Set[str]) -> 'ValidatorCallable': # assume the first argument is value has_kwargs = False if 'kwargs' in args: @@ -288,7 +293,7 @@ def _generic_validator_cls(validator: AnyCallable, sig: Signature, args: Set[str return lambda cls, v, values, field, config: validator(cls, v, values=values, field=field, config=config) -def _generic_validator_basic(validator: AnyCallable, sig: Signature, args: Set[str]) -> 'ValidatorCallable': +def _generic_validator_basic(validator: AnyCallable, sig: 'Signature', args: Set[str]) -> 'ValidatorCallable': has_kwargs = False if 'kwargs' in args: has_kwargs = True diff --git a/pydantic/color.py b/pydantic/color.py --- a/pydantic/color.py +++ b/pydantic/color.py @@ -42,17 +42,18 @@ def __getitem__(self, item: Any) -> Any: return self._tuple[item] -r_hex_short = re.compile(r'\s*(?:#|0x)?([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?\s*') -r_hex_long = re.compile(r'\s*(?:#|0x)?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?\s*') +# these are not compiled here to avoid import slowdown, they'll be compiled the first time they're used, then cached +r_hex_short = r'\s*(?:#|0x)?([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?\s*' +r_hex_long = r'\s*(?:#|0x)?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?\s*' _r_255 = r'(\d{1,3}(?:\.\d+)?)' _r_comma = r'\s*,\s*' -r_rgb = re.compile(fr'\s*rgb\(\s*{_r_255}{_r_comma}{_r_255}{_r_comma}{_r_255}\)\s*') +r_rgb = fr'\s*rgb\(\s*{_r_255}{_r_comma}{_r_255}{_r_comma}{_r_255}\)\s*' _r_alpha = r'(\d(?:\.\d+)?|\.\d+|\d{1,2}%)' -r_rgba = re.compile(fr'\s*rgba\(\s*{_r_255}{_r_comma}{_r_255}{_r_comma}{_r_255}{_r_comma}{_r_alpha}\s*\)\s*') +r_rgba = fr'\s*rgba\(\s*{_r_255}{_r_comma}{_r_255}{_r_comma}{_r_255}{_r_comma}{_r_alpha}\s*\)\s*' _r_h = r'(-?\d+(?:\.\d+)?|-?\.\d+)(deg|rad|turn)?' _r_sl = r'(\d{1,3}(?:\.\d+)?)%' -r_hsl = re.compile(fr'\s*hsl\(\s*{_r_h}{_r_comma}{_r_sl}{_r_comma}{_r_sl}\s*\)\s*') -r_hsla = re.compile(fr'\s*hsl\(\s*{_r_h}{_r_comma}{_r_sl}{_r_comma}{_r_sl}{_r_comma}{_r_alpha}\s*\)\s*') +r_hsl = fr'\s*hsl\(\s*{_r_h}{_r_comma}{_r_sl}{_r_comma}{_r_sl}\s*\)\s*' +r_hsla = fr'\s*hsl\(\s*{_r_h}{_r_comma}{_r_sl}{_r_comma}{_r_sl}{_r_comma}{_r_alpha}\s*\)\s*' # colors where the two hex characters are the same, if all colors match this the short version of hex colors can be used repeat_colors = {int(c * 2, 16) for c in '0123456789abcdef'} @@ -226,7 +227,7 @@ def parse_str(value: str) -> RGBA: else: return ints_to_rgba(r, g, b, None) - m = r_hex_short.fullmatch(value_lower) + m = re.fullmatch(r_hex_short, value_lower) if m: *rgb, a = m.groups() r, g, b = [int(v * 2, 16) for v in rgb] @@ -236,7 +237,7 @@ def parse_str(value: str) -> RGBA: alpha = None return ints_to_rgba(r, g, b, alpha) - m = r_hex_long.fullmatch(value_lower) + m = re.fullmatch(r_hex_long, value_lower) if m: *rgb, a = m.groups() r, g, b = [int(v, 16) for v in rgb] @@ -246,20 +247,20 @@ def parse_str(value: str) -> RGBA: alpha = None return ints_to_rgba(r, g, b, alpha) - m = r_rgb.fullmatch(value_lower) + m = re.fullmatch(r_rgb, value_lower) if m: return ints_to_rgba(*m.groups(), None) # type: ignore - m = r_rgba.fullmatch(value_lower) + m = re.fullmatch(r_rgba, value_lower) if m: return ints_to_rgba(*m.groups()) # type: ignore - m = r_hsl.fullmatch(value_lower) + m = re.fullmatch(r_hsl, value_lower) if m: h, h_units, s, l_ = m.groups() return parse_hsl(h, h_units, s, l_) - m = r_hsla.fullmatch(value_lower) + m = re.fullmatch(r_hsla, value_lower) if m: h, h_units, s, l_, a = m.groups() return parse_hsl(h, h_units, s, l_, parse_float_alpha(a)) diff --git a/pydantic/dataclasses.py b/pydantic/dataclasses.py --- a/pydantic/dataclasses.py +++ b/pydantic/dataclasses.py @@ -1,4 +1,3 @@ -import dataclasses from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, Optional, Type, TypeVar, Union from .class_validators import gather_all_validators @@ -66,6 +65,8 @@ def _process_class( frozen: bool, config: Optional[Type[Any]], ) -> 'DataclassType': + import dataclasses + post_init_original = getattr(_cls, '__post_init__', None) if post_init_original and post_init_original.__name__ == '_pydantic_post_init': post_init_original = None diff --git a/pydantic/datetime_parse.py b/pydantic/datetime_parse.py --- a/pydantic/datetime_parse.py +++ b/pydantic/datetime_parse.py @@ -23,7 +23,7 @@ date_re = re.compile(r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})$') time_re = re.compile( - r'(?P<hour>\d{1,2}):(?P<minute>\d{1,2})' r'(?::(?P<second>\d{1,2})(?:\.(?P<microsecond>\d{1,6})\d{0,6})?)?' + r'(?P<hour>\d{1,2}):(?P<minute>\d{1,2})(?::(?P<second>\d{1,2})(?:\.(?P<microsecond>\d{1,6})\d{0,6})?)?' ) datetime_re = re.compile( diff --git a/pydantic/json.py b/pydantic/json.py --- a/pydantic/json.py +++ b/pydantic/json.py @@ -1,5 +1,4 @@ import datetime -from dataclasses import asdict, is_dataclass from decimal import Decimal from enum import Enum from ipaddress import IPv4Address, IPv4Interface, IPv4Network, IPv6Address, IPv6Interface, IPv6Network @@ -42,6 +41,7 @@ def isoformat(o: Union[datetime.date, datetime.time]) -> str: def pydantic_encoder(obj: Any) -> Any: + from dataclasses import asdict, is_dataclass from .main import BaseModel if isinstance(obj, BaseModel): diff --git a/pydantic/networks.py b/pydantic/networks.py --- a/pydantic/networks.py +++ b/pydantic/networks.py @@ -9,22 +9,20 @@ _BaseAddress, _BaseNetwork, ) -from typing import TYPE_CHECKING, Any, Dict, Generator, Optional, Set, Tuple, Type, Union, cast, no_type_check +from typing import TYPE_CHECKING, Any, Dict, Generator, Optional, Pattern, Set, Tuple, Type, Union, cast, no_type_check from . import errors from .utils import Representation, update_not_none from .validators import constr_length_validator, str_validator if TYPE_CHECKING: + import email_validator from .fields import ModelField from .main import BaseConfig # noqa: F401 from .typing import AnyCallable CallableGenerator = Generator[AnyCallable, None, None] - -try: - import email_validator -except ImportError: +else: email_validator = None NetworkType = Union[str, bytes, int, Tuple[Union[str, bytes, int], Union[str, int]]] @@ -44,27 +42,47 @@ 'validate_email', ] -host_part_names = ('domain', 'ipv4', 'ipv6') -url_regex = re.compile( - r'(?:(?P<scheme>[a-z0-9]+?)://)?' # scheme - r'(?:(?P<user>[^\s:]+)(?::(?P<password>\S*))?@)?' # user info - r'(?:' - r'(?P<ipv4>(?:\d{1,3}\.){3}\d{1,3})|' # ipv4 - r'(?P<ipv6>\[[A-F0-9]*:[A-F0-9:]+\])|' # ipv6 - r'(?P<domain>[^\s/:?#]+)' # domain, validation occurs later - r')?' - r'(?::(?P<port>\d+))?' # port - r'(?P<path>/[^\s?]*)?' # path - r'(?:\?(?P<query>[^\s#]+))?' # query - r'(?:#(?P<fragment>\S+))?', # fragment - re.IGNORECASE, -) -_ascii_chunk = r'[_0-9a-z](?:[-_0-9a-z]{0,61}[_0-9a-z])?' + +_url_regex_cache = None +_ascii_domain_regex_cache = None +_int_domain_regex_cache = None _domain_ending = r'(?P<tld>\.[a-z]{2,63})?\.?' -ascii_domain_regex = re.compile(fr'(?:{_ascii_chunk}\.)*?{_ascii_chunk}{_domain_ending}', re.IGNORECASE) -_int_chunk = r'[_0-9a-\U00040000](?:[-_0-9a-\U00040000]{0,61}[_0-9a-\U00040000])?' -int_domain_regex = re.compile(fr'(?:{_int_chunk}\.)*?{_int_chunk}{_domain_ending}', re.IGNORECASE) + +def url_regex() -> Pattern[str]: + global _url_regex_cache + if _url_regex_cache is None: + _url_regex_cache = re.compile( + r'(?:(?P<scheme>[a-z0-9]+?)://)?' # scheme + r'(?:(?P<user>[^\s:]+)(?::(?P<password>\S*))?@)?' # user info + r'(?:' + r'(?P<ipv4>(?:\d{1,3}\.){3}\d{1,3})|' # ipv4 + r'(?P<ipv6>\[[A-F0-9]*:[A-F0-9:]+\])|' # ipv6 + r'(?P<domain>[^\s/:?#]+)' # domain, validation occurs later + r')?' + r'(?::(?P<port>\d+))?' # port + r'(?P<path>/[^\s?]*)?' # path + r'(?:\?(?P<query>[^\s#]+))?' # query + r'(?:#(?P<fragment>\S+))?', # fragment + re.IGNORECASE, + ) + return _url_regex_cache + + +def ascii_domain_regex() -> Pattern[str]: + global _ascii_domain_regex_cache + if _ascii_domain_regex_cache is None: + ascii_chunk = r'[_0-9a-z](?:[-_0-9a-z]{0,61}[_0-9a-z])?' + _ascii_domain_regex_cache = re.compile(fr'(?:{ascii_chunk}\.)*?{ascii_chunk}{_domain_ending}', re.IGNORECASE) + return _ascii_domain_regex_cache + + +def int_domain_regex() -> Pattern[str]: + global _int_domain_regex_cache + if _int_domain_regex_cache is None: + int_chunk = r'[_0-9a-\U00040000](?:[-_0-9a-\U00040000]{0,61}[_0-9a-\U00040000])?' + _int_domain_regex_cache = re.compile(fr'(?:{int_chunk}\.)*?{int_chunk}{_domain_ending}', re.IGNORECASE) + return _int_domain_regex_cache class AnyUrl(str): @@ -156,7 +174,7 @@ def validate(cls, value: Any, field: 'ModelField', config: 'BaseConfig') -> 'Any value = value.strip() url: str = cast(str, constr_length_validator(value, field, config)) - m = url_regex.match(url) + m = url_regex().match(url) # the regex should always match, if it doesn't please report with details of the URL tried assert m, 'URL regex failed unexpectedly' @@ -202,9 +220,9 @@ def validate_host(cls, parts: Dict[str, str]) -> Tuple[str, Optional[str], str, if host is None: raise errors.UrlHostError() elif host_type == 'domain': - d = ascii_domain_regex.fullmatch(host) + d = ascii_domain_regex().fullmatch(host) if d is None: - d = int_domain_regex.fullmatch(host) + d = int_domain_regex().fullmatch(host) if not d: raise errors.UrlHostError() host_type = 'int_domain' @@ -263,6 +281,14 @@ def stricturl( return type('UrlValue', (AnyUrl,), namespace) +def import_email_validator() -> None: + global email_validator + try: + import email_validator + except ImportError as e: + raise ImportError('email-validator is not installed, run `pip install pydantic[email]`') from e + + class EmailStr(str): @classmethod def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None: @@ -271,8 +297,7 @@ def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None: @classmethod def __get_validators__(cls) -> 'CallableGenerator': # included here and below so the error happens straight away - if email_validator is None: - raise ImportError('email-validator is not installed, run `pip install pydantic[email]`') + import_email_validator() yield str_validator yield cls.validate @@ -295,8 +320,7 @@ def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None: @classmethod def __get_validators__(cls) -> 'CallableGenerator': - if email_validator is None: - raise ImportError('email-validator is not installed, run `pip install pydantic[email]`') + import_email_validator() yield cls.validate @@ -394,7 +418,7 @@ def validate_email(value: Union[str]) -> Tuple[str, str]: See RFC 5322 but treat it with suspicion, there seems to exist no universally acknowledged test for a valid email! """ if email_validator is None: - raise ImportError('email-validator is not installed, run `pip install pydantic[email]`') + import_email_validator() m = pretty_email_regex.fullmatch(value) name: Optional[str] = None diff --git a/pydantic/parse.py b/pydantic/parse.py --- a/pydantic/parse.py +++ b/pydantic/parse.py @@ -62,5 +62,5 @@ def load_file( proto = Protocol.pickle return load_str_bytes( - b, proto=proto, content_type=content_type, encoding=encoding, allow_pickle=allow_pickle, json_loads=json_loads, + b, proto=proto, content_type=content_type, encoding=encoding, allow_pickle=allow_pickle, json_loads=json_loads ) diff --git a/pydantic/schema.py b/pydantic/schema.py --- a/pydantic/schema.py +++ b/pydantic/schema.py @@ -1,4 +1,3 @@ -import inspect import re import warnings from datetime import date, datetime, time, timedelta @@ -451,10 +450,12 @@ def model_process_schema( sub-models of the returned schema will be referenced, but their definitions will not be included in the schema. All the definitions are returned as the second value. """ + from inspect import getdoc + ref_prefix = ref_prefix or default_prefix known_models = known_models or set() s = {'title': model.__config__.title or model.__name__} - doc = inspect.getdoc(model) + doc = getdoc(model) if doc: s['description'] = doc known_models.add(model) diff --git a/pydantic/utils.py b/pydantic/utils.py --- a/pydantic/utils.py +++ b/pydantic/utils.py @@ -1,9 +1,5 @@ -import inspect -import platform -import sys import warnings -from importlib import import_module -from pathlib import Path +from types import GeneratorType from typing import ( TYPE_CHECKING, AbstractSet, @@ -37,6 +33,8 @@ def import_string(dotted_path: str) -> Any: Stolen approximately from django. Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import fails. """ + from importlib import import_module + try: module_path, class_name = dotted_path.strip(' ').rsplit('.', 1) except ValueError as e: @@ -70,7 +68,7 @@ def truncate(v: Union[str], *, max_len: int = 80) -> str: def sequence_like(v: AnyType) -> bool: - return isinstance(v, (list, tuple, set, frozenset)) or inspect.isgenerator(v) + return isinstance(v, (list, tuple, set, frozenset, GeneratorType)) def validate_field_name(bases: List[Type['BaseModel']], field_name: str) -> None: @@ -337,6 +335,11 @@ def __repr_args__(self) -> 'ReprArgs': def version_info() -> str: + import platform + import sys + from importlib import import_module + from pathlib import Path + from .main import compiled from .version import VERSION diff --git a/pydantic/version.py b/pydantic/version.py --- a/pydantic/version.py +++ b/pydantic/version.py @@ -1,5 +1,3 @@ -from distutils.version import StrictVersion - __all__ = ['VERSION'] -VERSION = StrictVersion('1.3') +VERSION = '1.3'
pydantic/pydantic
8364983545157e3edfe019c636bc82d98b153ea3
It's a matter of taste, I prefer running tests first. It doesn't make much difference since all parts are pretty fast for pydantic. Happy to change if others also want a change. On Wed, Nov 27, 2019, 23:44 Arseny Boykov <[email protected]> wrote: > Question > > Currently calling make in project will first run all tests and only after > that will run lint checks. > Is there any reason for that? > It doesn't make sense to me as code analysis are complete much faster. Now > I have to either run code analyses separately before running make, or wait > while all tests will pass. > > So can we change this: > > .PHONY: all > all: testcov lint mypy > > to this: > > .PHONY: all > all: lint mypy testcov > ? > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <https://github.com/samuelcolvin/pydantic/issues/1039?email_source=notifications&email_token=AA62GGMGA6M4B7PW4IH3EZ3QV4A5LA5CNFSM4JSNNTRKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H4RLTLA>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AA62GGNOYN6C3K7G7MTB4RDQV4A5LANCNFSM4JSNNTRA> > . > I’m fine either way. I’d say I have a weak preference for the order @MrMrRobat has proposed though. I frequently find myself hitting a stupid linting issue after running all the tests, then get annoyed because I feel like I should probably make sure everything works after fixing the linting issue by running the tests again. But it’s a pretty minor thing either way. Okay let's change. PR welcome On Thu, Nov 28, 2019, 09:21 dmontagu <[email protected]> wrote: > I’m fine either way. I’d say I have a weak preference for the order > @MrMrRobat <https://github.com/MrMrRobat> has proposed though. > > I frequently find myself hitting a stupid linting issue after running all > the tests, then get annoyed because I feel like I should probably make sure > everything works after fixing the linting issue by running the tests again. > But it’s a pretty minor thing either way. > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/samuelcolvin/pydantic/issues/1039?email_source=notifications&email_token=AA62GGJLA7MV7FQHPQRRWETQV6ESHA5CNFSM4JSNNTRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFL6U6Q#issuecomment-559409786>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AA62GGIVV2UKVG4SXJZCJ2LQV6ESHANCNFSM4JSNNTRA> > . >
diff --git a/tests/test_schema.py b/tests/test_schema.py --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -1743,6 +1743,6 @@ class Model(BaseModel): 'type': 'array', 'items': {'type': 'integer'}, 'uniqueItems': True, - }, + } }, } diff --git a/tests/test_utils.py b/tests/test_utils.py --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,12 +1,13 @@ import os import re import string +from distutils.version import StrictVersion from enum import Enum from typing import NewType, Union import pytest -from pydantic import BaseModel +from pydantic import VERSION, BaseModel from pydantic.color import Color from pydantic.dataclasses import dataclass from pydantic.fields import Undefined @@ -292,3 +293,7 @@ def test_version_info(): s = version_info() assert re.match(' *pydantic version: ', s) assert s.count('\n') == 5 + + +def test_version_strict(): + assert str(StrictVersion(VERSION)) == VERSION
Change `make` commands order in Makefile # Question Currently calling `make` in project will first run all tests and only after that will run lint checks. Is there any reason for that? It doesn't make sense to me as code analysis are complete much faster. Now I have to either run code analyses separately before running make, or wait while all tests will pass. So can we change this: ```bash .PHONY: all all: testcov lint mypy ``` to this: ``` .PHONY: all all: lint mypy testcov ``` ?
0.0
8364983545157e3edfe019c636bc82d98b153ea3
[ "tests/test_utils.py::test_version_strict" ]
[ "tests/test_schema.py::test_key", "tests/test_schema.py::test_by_alias", "tests/test_schema.py::test_sub_model", "tests/test_schema.py::test_schema_class", "tests/test_schema.py::test_schema_repr", "tests/test_schema.py::test_schema_class_by_alias", "tests/test_schema.py::test_choices", "tests/test_schema.py::test_json_schema", "tests/test_schema.py::test_list_sub_model", "tests/test_schema.py::test_optional", "tests/test_schema.py::test_any", "tests/test_schema.py::test_set", "tests/test_schema.py::test_const_str", "tests/test_schema.py::test_const_false", "tests/test_schema.py::test_tuple[tuple-expected_schema0]", "tests/test_schema.py::test_tuple[field_type1-expected_schema1]", "tests/test_schema.py::test_tuple[field_type2-expected_schema2]", "tests/test_schema.py::test_bool", "tests/test_schema.py::test_strict_bool", "tests/test_schema.py::test_dict", "tests/test_schema.py::test_list", "tests/test_schema.py::test_list_union_dict[field_type0-expected_schema0]", "tests/test_schema.py::test_list_union_dict[field_type1-expected_schema1]", "tests/test_schema.py::test_list_union_dict[field_type2-expected_schema2]", "tests/test_schema.py::test_list_union_dict[field_type3-expected_schema3]", "tests/test_schema.py::test_list_union_dict[field_type4-expected_schema4]", "tests/test_schema.py::test_date_types[datetime-expected_schema0]", "tests/test_schema.py::test_date_types[date-expected_schema1]", "tests/test_schema.py::test_date_types[time-expected_schema2]", "tests/test_schema.py::test_date_types[timedelta-expected_schema3]", "tests/test_schema.py::test_str_basic_types[field_type0-expected_schema0]", "tests/test_schema.py::test_str_basic_types[field_type1-expected_schema1]", "tests/test_schema.py::test_str_basic_types[field_type2-expected_schema2]", "tests/test_schema.py::test_str_basic_types[field_type3-expected_schema3]", "tests/test_schema.py::test_str_constrained_types[StrictStr-expected_schema0]", "tests/test_schema.py::test_str_constrained_types[ConstrainedStr-expected_schema1]", "tests/test_schema.py::test_str_constrained_types[ConstrainedStrValue-expected_schema2]", "tests/test_schema.py::test_special_str_types[AnyUrl-expected_schema0]", "tests/test_schema.py::test_special_str_types[UrlValue-expected_schema1]", "tests/test_schema.py::test_email_str_types[EmailStr-email]", "tests/test_schema.py::test_email_str_types[NameEmail-name-email]", "tests/test_schema.py::test_secret_types[SecretBytes-string]", "tests/test_schema.py::test_secret_types[SecretStr-string]", "tests/test_schema.py::test_special_int_types[ConstrainedInt-expected_schema0]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema1]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema2]", "tests/test_schema.py::test_special_int_types[ConstrainedIntValue-expected_schema3]", "tests/test_schema.py::test_special_int_types[PositiveInt-expected_schema4]", "tests/test_schema.py::test_special_int_types[NegativeInt-expected_schema5]", "tests/test_schema.py::test_special_float_types[ConstrainedFloat-expected_schema0]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema1]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema2]", "tests/test_schema.py::test_special_float_types[ConstrainedFloatValue-expected_schema3]", "tests/test_schema.py::test_special_float_types[PositiveFloat-expected_schema4]", "tests/test_schema.py::test_special_float_types[NegativeFloat-expected_schema5]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimal-expected_schema6]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema7]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema8]", "tests/test_schema.py::test_special_float_types[ConstrainedDecimalValue-expected_schema9]", "tests/test_schema.py::test_uuid_types[UUID-uuid]", "tests/test_schema.py::test_uuid_types[UUID1-uuid1]", "tests/test_schema.py::test_uuid_types[UUID3-uuid3]", "tests/test_schema.py::test_uuid_types[UUID4-uuid4]", "tests/test_schema.py::test_uuid_types[UUID5-uuid5]", "tests/test_schema.py::test_path_types[FilePath-file-path]", "tests/test_schema.py::test_path_types[DirectoryPath-directory-path]", "tests/test_schema.py::test_path_types[Path-path]", "tests/test_schema.py::test_json_type", "tests/test_schema.py::test_ipv4address_type", "tests/test_schema.py::test_ipv6address_type", "tests/test_schema.py::test_ipvanyaddress_type", "tests/test_schema.py::test_ipv4interface_type", "tests/test_schema.py::test_ipv6interface_type", "tests/test_schema.py::test_ipvanyinterface_type", "tests/test_schema.py::test_ipv4network_type", "tests/test_schema.py::test_ipv6network_type", "tests/test_schema.py::test_ipvanynetwork_type", "tests/test_schema.py::test_callable_type[annotation0]", "tests/test_schema.py::test_callable_type[annotation1]", "tests/test_schema.py::test_error_non_supported_types", "tests/test_schema.py::test_flat_models_unique_models", "tests/test_schema.py::test_flat_models_with_submodels", "tests/test_schema.py::test_flat_models_with_submodels_from_sequence", "tests/test_schema.py::test_model_name_maps", "tests/test_schema.py::test_schema_overrides", "tests/test_schema.py::test_schema_from_models", "tests/test_schema.py::test_schema_with_ref_prefix", "tests/test_schema.py::test_schema_no_definitions", "tests/test_schema.py::test_list_default", "tests/test_schema.py::test_dict_default", "tests/test_schema.py::test_constraints_schema[kwargs0-str-expected_extra0]", "tests/test_schema.py::test_constraints_schema[kwargs1-ConstrainedStrValue-expected_extra1]", "tests/test_schema.py::test_constraints_schema[kwargs2-str-expected_extra2]", "tests/test_schema.py::test_constraints_schema[kwargs3-bytes-expected_extra3]", "tests/test_schema.py::test_constraints_schema[kwargs4-str-expected_extra4]", "tests/test_schema.py::test_constraints_schema[kwargs5-int-expected_extra5]", "tests/test_schema.py::test_constraints_schema[kwargs6-int-expected_extra6]", "tests/test_schema.py::test_constraints_schema[kwargs7-int-expected_extra7]", "tests/test_schema.py::test_constraints_schema[kwargs8-int-expected_extra8]", "tests/test_schema.py::test_constraints_schema[kwargs9-int-expected_extra9]", "tests/test_schema.py::test_constraints_schema[kwargs10-float-expected_extra10]", "tests/test_schema.py::test_constraints_schema[kwargs11-float-expected_extra11]", "tests/test_schema.py::test_constraints_schema[kwargs12-float-expected_extra12]", "tests/test_schema.py::test_constraints_schema[kwargs13-float-expected_extra13]", "tests/test_schema.py::test_constraints_schema[kwargs14-float-expected_extra14]", "tests/test_schema.py::test_constraints_schema[kwargs15-Decimal-expected_extra15]", "tests/test_schema.py::test_constraints_schema[kwargs16-Decimal-expected_extra16]", "tests/test_schema.py::test_constraints_schema[kwargs17-Decimal-expected_extra17]", "tests/test_schema.py::test_constraints_schema[kwargs18-Decimal-expected_extra18]", "tests/test_schema.py::test_constraints_schema[kwargs19-Decimal-expected_extra19]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs0-int]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs1-float]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs2-Decimal]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs3-int]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs4-str]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs5-bytes]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs6-str]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs7-bool]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs9-type_9]", "tests/test_schema.py::test_unenforced_constraints_schema[kwargs10-ConstrainedListValue]", "tests/test_schema.py::test_constraints_schema_validation[kwargs0-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs1-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs2-bytes-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs3-str-foo]", "tests/test_schema.py::test_constraints_schema_validation[kwargs4-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs5-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs6-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs7-int-2]", "tests/test_schema.py::test_constraints_schema_validation[kwargs8-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs9-int-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs10-int-5]", "tests/test_schema.py::test_constraints_schema_validation[kwargs11-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs12-float-2.1]", "tests/test_schema.py::test_constraints_schema_validation[kwargs13-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs14-float-4.9]", "tests/test_schema.py::test_constraints_schema_validation[kwargs15-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs16-float-2.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs17-float-3.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs18-float-5.0]", "tests/test_schema.py::test_constraints_schema_validation[kwargs19-float-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs20-float-3]", "tests/test_schema.py::test_constraints_schema_validation[kwargs21-Decimal-value21]", "tests/test_schema.py::test_constraints_schema_validation[kwargs22-Decimal-value22]", "tests/test_schema.py::test_constraints_schema_validation[kwargs23-Decimal-value23]", "tests/test_schema.py::test_constraints_schema_validation[kwargs24-Decimal-value24]", "tests/test_schema.py::test_constraints_schema_validation[kwargs25-Decimal-value25]", "tests/test_schema.py::test_constraints_schema_validation[kwargs26-Decimal-value26]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs0-str-foobar]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs1-str-f]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs2-str-bar]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs3-int-2]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs4-int-5]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs5-int-1]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs6-int-6]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs7-float-2.0]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs8-float-5.0]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs9-float-1.9]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs10-float-5.1]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs11-Decimal-value11]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs12-Decimal-value12]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs13-Decimal-value13]", "tests/test_schema.py::test_constraints_schema_validation_raises[kwargs14-Decimal-value14]", "tests/test_schema.py::test_schema_kwargs", "tests/test_schema.py::test_schema_dict_constr", "tests/test_schema.py::test_bytes_constrained_types[ConstrainedBytes-expected_schema0]", "tests/test_schema.py::test_bytes_constrained_types[ConstrainedBytesValue-expected_schema1]", "tests/test_schema.py::test_optional_dict", "tests/test_schema.py::test_optional_validator", "tests/test_schema.py::test_field_with_validator", "tests/test_schema.py::test_known_model_optimization", "tests/test_schema.py::test_root", "tests/test_schema.py::test_root_list", "tests/test_schema.py::test_root_nested_model", "tests/test_schema.py::test_new_type_schema", "tests/test_schema.py::test_literal_schema", "tests/test_schema.py::test_color_type", "tests/test_schema.py::test_model_with_schema_extra", "tests/test_schema.py::test_model_with_schema_extra_callable", "tests/test_schema.py::test_model_with_extra_forbidden", "tests/test_schema.py::test_enforced_constraints[int-kwargs0-field_schema0]", "tests/test_schema.py::test_enforced_constraints[annotation1-kwargs1-field_schema1]", "tests/test_schema.py::test_enforced_constraints[annotation2-kwargs2-field_schema2]", "tests/test_schema.py::test_enforced_constraints[annotation3-kwargs3-field_schema3]", "tests/test_schema.py::test_enforced_constraints[annotation4-kwargs4-field_schema4]", "tests/test_schema.py::test_enforced_constraints[annotation5-kwargs5-field_schema5]", "tests/test_schema.py::test_enforced_constraints[annotation6-kwargs6-field_schema6]", "tests/test_schema.py::test_enforced_constraints[annotation7-kwargs7-field_schema7]", "tests/test_schema.py::test_real_vs_phony_constraints", "tests/test_schema.py::test_conlist", "tests/test_schema.py::test_subfield_field_info", "tests/test_schema.py::test_dataclass", "tests/test_schema.py::test_schema_attributes", "tests/test_schema.py::test_path_modify_schema", "tests/test_schema.py::test_frozen_set", "tests/test_utils.py::test_import_module", "tests/test_utils.py::test_import_module_invalid", "tests/test_utils.py::test_import_no_attr", "tests/test_utils.py::test_display_as_type[str-str]", "tests/test_utils.py::test_display_as_type[string-str]", "tests/test_utils.py::test_display_as_type[value2-Union[str,", "tests/test_utils.py::test_display_as_type_enum", "tests/test_utils.py::test_display_as_type_enum_int", "tests/test_utils.py::test_display_as_type_enum_str", "tests/test_utils.py::test_lenient_issubclass", "tests/test_utils.py::test_lenient_issubclass_is_lenient", "tests/test_utils.py::test_truncate[object-<class", "tests/test_utils.py::test_truncate[abcdefghijklmnopqrstuvwxyz-'abcdefghijklmnopq\\u2026']", "tests/test_utils.py::test_truncate[input_value2-[0,", "tests/test_utils.py::test_value_items", "tests/test_utils.py::test_value_items_error", "tests/test_utils.py::test_is_new_type", "tests/test_utils.py::test_new_type_supertype", "tests/test_utils.py::test_pretty", "tests/test_utils.py::test_pretty_color", "tests/test_utils.py::test_devtools_output", "tests/test_utils.py::test_devtools_output_validation_error", "tests/test_utils.py::test_deep_update[mapping0-updating_mapping0-expected_mapping0-extra", "tests/test_utils.py::test_deep_update[mapping1-updating_mapping1-expected_mapping1-values", "tests/test_utils.py::test_deep_update[mapping2-updating_mapping2-expected_mapping2-values", "tests/test_utils.py::test_deep_update[mapping3-updating_mapping3-expected_mapping3-deeply", "tests/test_utils.py::test_deep_update_is_not_mutating", "tests/test_utils.py::test_undefined_repr", "tests/test_utils.py::test_get_model", "tests/test_utils.py::test_version_info" ]
{ "failed_lite_validators": [ "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2019-12-26 18:11:23+00:00
mit
4,729
pydantic__pydantic-1148
diff --git a/pydantic/networks.py b/pydantic/networks.py --- a/pydantic/networks.py +++ b/pydantic/networks.py @@ -53,7 +53,7 @@ def url_regex() -> Pattern[str]: global _url_regex_cache if _url_regex_cache is None: _url_regex_cache = re.compile( - r'(?:(?P<scheme>[a-z0-9]+?)://)?' # scheme + r'(?:(?P<scheme>[a-z][a-z0-9+\-.]+)://)?' # scheme https://tools.ietf.org/html/rfc3986#appendix-A r'(?:(?P<user>[^\s:]+)(?::(?P<password>\S*))?@)?' # user info r'(?:' r'(?P<ipv4>(?:\d{1,3}\.){3}\d{1,3})|' # ipv4
pydantic/pydantic
cd8b504568a7da3c0649347e2bcec4e3a4e79143
Note that according to Appendix A of [rfc2396](http://www.ietf.org/rfc/rfc2396.txt) a URI scheme is defined as: ``` scheme = alpha *( alpha | digit | "+" | "-" | "." ) ``` (search the document for "Collected BNF for URI"). Edit: [RFC3986](https://tools.ietf.org/html/rfc3986) is probably more up to date. [Appendix A](https://tools.ietf.org/html/rfc3986#appendix-A) of that document describes scheme as: ``` scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) ``` In any case the `+`, `-` and `.` characters are all valid in the scheme part. Thanks for reporting, please could you submit a PR for this? I'll look into it. Will need to get work clearance etc tho, so it might take a little while. Thank you, let me know if it's too much work to be worth it and/or urgent, if so I can do it. It would require legal review, so if you didn't mind doing it, that would be very much appreciated. wow :sleeping:, there are advantages to working for a startup. I'll do it.
diff --git a/tests/test_networks.py b/tests/test_networks.py --- a/tests/test_networks.py +++ b/tests/test_networks.py @@ -18,6 +18,10 @@ 'https://example.org/whatever/next/', 'postgres://user:pass@localhost:5432/app', 'postgres://just-user@localhost:5432/app', + 'postgresql+psycopg2://postgres:postgres@localhost:5432/hatch', + 'foo-bar://example.org', + 'foo.bar://example.org', + 'foo0bar://example.org', 'https://example.org', 'http://localhost', 'http://localhost/', @@ -77,6 +81,8 @@ class Model(BaseModel): ('abc', 'value_error.url.scheme', 'invalid or missing URL scheme', None), ('..', 'value_error.url.scheme', 'invalid or missing URL scheme', None), ('/', 'value_error.url.scheme', 'invalid or missing URL scheme', None), + ('+http://example.com/', 'value_error.url.scheme', 'invalid or missing URL scheme', None), + ('ht*tp://example.com/', 'value_error.url.scheme', 'invalid or missing URL scheme', None), (' ', 'value_error.any_str.min_length', 'ensure this value has at least 1 characters', {'limit_value': 1}), ('', 'value_error.any_str.min_length', 'ensure this value has at least 1 characters', {'limit_value': 1}), (None, 'type_error.none.not_allowed', 'none is not an allowed value', None),
url_regex doesn't correctly match all allowed characters in a URI # Bug ```python from pydantic.networks import url_regex m=url_regex.match("postgresql+psycopg2://postgres:postgres@localhost:5432/hatch") parts = m.groupdict() parts ``` produces the following incorrect matching: ```python {'scheme': None, 'user': 'postgresql+psycopg2', 'password': '//postgres:postgres', 'ipv4': None, 'ipv6': None, 'domain': 'localhost', 'port': '5432', 'path': '/hatch', 'query': None, 'fragment': None} ``` This is with Python 3.7.5 on OSX, pydantic version 1.2
0.0
cd8b504568a7da3c0649347e2bcec4e3a4e79143
[ "tests/test_networks.py::test_any_url_success[postgresql+psycopg2://postgres:postgres@localhost:5432/hatch]", "tests/test_networks.py::test_any_url_success[foo-bar://example.org]", "tests/test_networks.py::test_any_url_success[foo.bar://example.org]" ]
[ "tests/test_networks.py::test_any_url_success[http://example.org]", "tests/test_networks.py::test_any_url_success[http://test]", "tests/test_networks.py::test_any_url_success[http://localhost0]", "tests/test_networks.py::test_any_url_success[https://example.org/whatever/next/]", "tests/test_networks.py::test_any_url_success[postgres://user:pass@localhost:5432/app]", "tests/test_networks.py::test_any_url_success[postgres://just-user@localhost:5432/app]", "tests/test_networks.py::test_any_url_success[foo0bar://example.org]", "tests/test_networks.py::test_any_url_success[https://example.org]", "tests/test_networks.py::test_any_url_success[http://localhost1]", "tests/test_networks.py::test_any_url_success[http://localhost/]", "tests/test_networks.py::test_any_url_success[http://localhost:8000]", "tests/test_networks.py::test_any_url_success[http://localhost:8000/]", "tests/test_networks.py::test_any_url_success[https://foo_bar.example.com/]", "tests/test_networks.py::test_any_url_success[ftp://example.org]", "tests/test_networks.py::test_any_url_success[ftps://example.org]", "tests/test_networks.py::test_any_url_success[http://example.co.jp]", "tests/test_networks.py::test_any_url_success[http://www.example.com/a%C2%B1b]", "tests/test_networks.py::test_any_url_success[http://www.example.com/~username/]", "tests/test_networks.py::test_any_url_success[http://info.example.com?fred]", "tests/test_networks.py::test_any_url_success[http://info.example.com/?fred]", "tests/test_networks.py::test_any_url_success[http://xn--mgbh0fb.xn--kgbechtv/]", "tests/test_networks.py::test_any_url_success[http://example.com/blue/red%3Fand+green]", "tests/test_networks.py::test_any_url_success[http://www.example.com/?array%5Bkey%5D=value]", "tests/test_networks.py::test_any_url_success[http://xn--rsum-bpad.example.org/]", "tests/test_networks.py::test_any_url_success[http://123.45.67.8/]", "tests/test_networks.py::test_any_url_success[http://123.45.67.8:8329/]", "tests/test_networks.py::test_any_url_success[http://[2001:db8::ff00:42]:8329]", "tests/test_networks.py::test_any_url_success[http://[2001::1]:8329]", "tests/test_networks.py::test_any_url_success[http://[2001:db8::1]/]", "tests/test_networks.py::test_any_url_success[http://www.example.com:8000/foo]", "tests/test_networks.py::test_any_url_success[http://www.cwi.nl:80/%7Eguido/Python.html]", "tests/test_networks.py::test_any_url_success[https://www.python.org/\\u043f\\u0443\\u0442\\u044c]", "tests/test_networks.py::test_any_url_success[http://\\u0430\\u043d\\u0434\\u0440\\u0435\\[email protected]]", "tests/test_networks.py::test_any_url_success[https://example.com]", "tests/test_networks.py::test_any_url_success[https://exam_ple.com/]", "tests/test_networks.py::test_any_url_invalid[http:///example.com/-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https:///example.com/-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://.example.com:8000/foo-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https://example.org\\\\-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https://exampl$e.org-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://??-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://.-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://..-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https://example.org", "tests/test_networks.py::test_any_url_invalid[$https://example.org-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[../icons/logo.gif-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[abc-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[..-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[/-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[+http://example.com/-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[ht*tp://example.com/-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[", "tests/test_networks.py::test_any_url_invalid[-value_error.any_str.min_length-ensure", "tests/test_networks.py::test_any_url_invalid[None-type_error.none.not_allowed-none", "tests/test_networks.py::test_any_url_invalid[http://2001:db8::ff00:42:8329-value_error.url.extra-URL", "tests/test_networks.py::test_any_url_invalid[http://[192.168.1.1]:8329-value_error.url.host-URL", "tests/test_networks.py::test_any_url_obj", "tests/test_networks.py::test_http_url_success[http://example.org]", "tests/test_networks.py::test_http_url_success[http://example.org/foobar]", "tests/test_networks.py::test_http_url_success[http://example.org.]", "tests/test_networks.py::test_http_url_success[http://example.org./foobar]", "tests/test_networks.py::test_http_url_success[HTTP://EXAMPLE.ORG]", "tests/test_networks.py::test_http_url_success[https://example.org]", "tests/test_networks.py::test_http_url_success[https://example.org?a=1&b=2]", "tests/test_networks.py::test_http_url_success[https://example.org#a=3;b=3]", "tests/test_networks.py::test_http_url_success[https://foo_bar.example.com/]", "tests/test_networks.py::test_http_url_success[https://exam_ple.com/]", "tests/test_networks.py::test_http_url_invalid[ftp://example.com/-value_error.url.scheme-URL", "tests/test_networks.py::test_http_url_invalid[http://foobar/-value_error.url.host-URL", "tests/test_networks.py::test_http_url_invalid[http://localhost/-value_error.url.host-URL", "tests/test_networks.py::test_http_url_invalid[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-value_error.any_str.max_length-ensure", "tests/test_networks.py::test_coerse_url[", "tests/test_networks.py::test_coerse_url[https://www.example.com-https://www.example.com]", "tests/test_networks.py::test_coerse_url[https://www.\\u0430\\u0440\\u0440\\u04cf\\u0435.com/-https://www.xn--80ak6aa92e.com/]", "tests/test_networks.py::test_coerse_url[https://exampl\\xa3e.org-https://xn--example-gia.org]", "tests/test_networks.py::test_postgres_dsns", "tests/test_networks.py::test_redis_dsns", "tests/test_networks.py::test_custom_schemes", "tests/test_networks.py::test_build_url[kwargs0-ws://[email protected]]", "tests/test_networks.py::test_build_url[kwargs1-ws://foo:[email protected]]", "tests/test_networks.py::test_build_url[kwargs2-ws://example.net?a=b#c=d]", "tests/test_networks.py::test_build_url[kwargs3-http://example.net:1234]", "tests/test_networks.py::test_son", "tests/test_networks.py::test_address_valid[[email protected]@example.com]", "tests/test_networks.py::test_address_valid[[email protected]@muelcolvin.com]", "tests/test_networks.py::test_address_valid[Samuel", "tests/test_networks.py::test_address_valid[foobar", "tests/test_networks.py::test_address_valid[", "tests/test_networks.py::test_address_valid[[email protected]", "tests/test_networks.py::test_address_valid[foo", "tests/test_networks.py::test_address_valid[FOO", "tests/test_networks.py::test_address_valid[<[email protected]>", "tests/test_networks.py::test_address_valid[\\xf1o\\xf1\\[email protected]\\xf1o\\xf1\\xf3-\\xf1o\\xf1\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u6211\\[email protected]\\u6211\\u8cb7-\\u6211\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u7532\\u6590\\u9ed2\\u5ddd\\u65e5\\[email protected]\\u7532\\u6590\\u9ed2\\u5ddd\\u65e5\\u672c-\\u7532\\u6590\\u9ed2\\u5ddd\\u65e5\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u0447\\u0435\\u0431\\u0443\\u0440\\u0430\\u0448\\u043a\\u0430\\u044f\\u0449\\u0438\\u043a-\\u0441-\\u0430\\u043f\\u0435\\u043b\\u044c\\u0441\\u0438\\u043d\\u0430\\u043c\\u0438.\\u0440\\[email protected]\\u0447\\u0435\\u0431\\u0443\\u0440\\u0430\\u0448\\u043a\\u0430\\u044f\\u0449\\u0438\\u043a-\\u0441-\\u0430\\u043f\\u0435\\u043b\\u044c\\u0441\\u0438\\u043d\\u0430\\u043c\\u0438.\\u0440\\u0444-\\u0447\\u0435\\u0431\\u0443\\u0440\\u0430\\u0448\\u043a\\u0430\\u044f\\u0449\\u0438\\u043a-\\u0441-\\u0430\\u043f\\u0435\\u043b\\u044c\\u0441\\u0438\\u043d\\u0430\\u043c\\u0438.\\u0440\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u0909\\u0926\\u093e\\u0939\\u0930\\u0923.\\u092a\\u0930\\u0940\\u0915\\u094d\\[email protected]\\u0909\\u0926\\u093e\\u0939\\u0930\\u0923.\\u092a\\u0930\\u0940\\u0915\\u094d\\u0937-\\u0909\\u0926\\u093e\\u0939\\u0930\\u0923.\\u092a\\u0930\\u0940\\u0915\\u094d\\[email protected]]", "tests/test_networks.py::test_address_valid[[email protected]@example.com]", "tests/test_networks.py::test_address_valid[[email protected]", "tests/test_networks.py::test_address_valid[\\u03b9\\u03c9\\u03ac\\u03bd\\u03bd\\u03b7\\u03c2@\\u03b5\\u03b5\\u03c4\\u03c4.gr-\\u03b9\\u03c9\\u03ac\\u03bd\\u03bd\\u03b7\\u03c2-\\u03b9\\u03c9\\u03ac\\u03bd\\u03bd\\u03b7\\u03c2@\\u03b5\\u03b5\\u03c4\\u03c4.gr]", "tests/test_networks.py::test_address_invalid[f", "tests/test_networks.py::test_address_invalid[foo.bar@exam\\nple.com", "tests/test_networks.py::test_address_invalid[foobar]", "tests/test_networks.py::test_address_invalid[foobar", "tests/test_networks.py::test_address_invalid[@example.com]", "tests/test_networks.py::test_address_invalid[[email protected]]", "tests/test_networks.py::test_address_invalid[[email protected]]", "tests/test_networks.py::test_address_invalid[foo", "tests/test_networks.py::test_address_invalid[foo@[email protected]]", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[\"@example.com0]", "tests/test_networks.py::test_address_invalid[\"@example.com1]", "tests/test_networks.py::test_address_invalid[,@example.com]", "tests/test_networks.py::test_email_str", "tests/test_networks.py::test_name_email" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2020-01-06 15:45:11+00:00
mit
4,730
pydantic__pydantic-1174
diff --git a/pydantic/main.py b/pydantic/main.py --- a/pydantic/main.py +++ b/pydantic/main.py @@ -284,7 +284,7 @@ def __setattr__(self, name, value): elif self.__config__.validate_assignment: known_field = self.__fields__.get(name, None) if known_field: - value, error_ = known_field.validate(value, self.dict(exclude={name}), loc=name) + value, error_ = known_field.validate(value, self.dict(exclude={name}), loc=name, cls=self.__class__) if error_: raise ValidationError([error_], type(self)) self.__dict__[name] = value
pydantic/pydantic
718b7fe643fc49d1b4261338f68c2216a3391df4
diff --git a/tests/test_validators.py b/tests/test_validators.py --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -1017,3 +1017,24 @@ def example_root_validator(cls, values): with pytest.raises(ValidationError): ModelB(a='a') assert not b_called + + +def test_assignment_validator_cls(): + validator_calls = 0 + + class Model(BaseModel): + name: str + + class Config: + validate_assignment = True + + @validator('name') + def check_foo(cls, value): + nonlocal validator_calls + validator_calls += 1 + assert cls == Model + return value + + m = Model(name='hello') + m.name = 'goodbye' + assert validator_calls == 2
cls is None in validator when validate_assignment is True # Bug When we set config value `validate_assignment` to True and define custom validator for a field, and try to set value for the field, we get None in `cls` argument in the validator method instead of expected model class object. In my case I want to store some data in model class object that I want to use for validation and I cannot get it via `cls` because `cls` is None. Of course I can use model class object directly, but this behavior is ambiguous and looks like a bug anyway. Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`: ``` pydantic version: 1.3 pydantic compiled: False install path: C:\Users\espdev\AppData\Local\pypoetry\Cache\virtualenvs\ms3eI9mF-py3.8\Lib\site-packages\pydantic python version: 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] platform: Windows-10-10.0.18362-SP0 optional deps. installed: [] ``` A minimal example: ```py from pydantic import BaseModel, StrictStr, validator class Model(BaseModel): name: StrictStr class Config: validate_assignment = True @validator('name') def _validate_foo(cls, value): if cls is None: raise ValueError('cls is None') return value if __name__ == '__main__': m = Model(name='hello') # OK m.name = 'goodbye' # <-- ValidationError "cls is None" ``` ``` pydantic.error_wrappers.ValidationError: 1 validation error for Model name cls is None (type=value_error) ```
0.0
718b7fe643fc49d1b4261338f68c2216a3391df4
[ "tests/test_validators.py::test_assignment_validator_cls" ]
[ "tests/test_validators.py::test_simple", "tests/test_validators.py::test_int_validation", "tests/test_validators.py::test_frozenset_validation", "tests/test_validators.py::test_validate_whole", "tests/test_validators.py::test_validate_kwargs", "tests/test_validators.py::test_validate_pre_error", "tests/test_validators.py::test_validating_assignment_ok", "tests/test_validators.py::test_validating_assignment_fail", "tests/test_validators.py::test_validating_assignment_value_change", "tests/test_validators.py::test_validating_assignment_extra", "tests/test_validators.py::test_validating_assignment_dict", "tests/test_validators.py::test_validate_multiple", "tests/test_validators.py::test_classmethod", "tests/test_validators.py::test_duplicates", "tests/test_validators.py::test_use_bare", "tests/test_validators.py::test_use_no_fields", "tests/test_validators.py::test_validate_always", "tests/test_validators.py::test_validate_not_always", "tests/test_validators.py::test_wildcard_validators", "tests/test_validators.py::test_wildcard_validator_error", "tests/test_validators.py::test_invalid_field", "tests/test_validators.py::test_validate_child", "tests/test_validators.py::test_validate_child_extra", "tests/test_validators.py::test_validate_child_all", "tests/test_validators.py::test_validate_parent", "tests/test_validators.py::test_validate_parent_all", "tests/test_validators.py::test_inheritance_keep", "tests/test_validators.py::test_inheritance_replace", "tests/test_validators.py::test_inheritance_new", "tests/test_validators.py::test_validation_each_item", "tests/test_validators.py::test_key_validation", "tests/test_validators.py::test_validator_always_optional", "tests/test_validators.py::test_validator_always_pre", "tests/test_validators.py::test_validator_always_post", "tests/test_validators.py::test_validator_always_post_optional", "tests/test_validators.py::test_datetime_validator", "tests/test_validators.py::test_pre_called_once", "tests/test_validators.py::test_make_generic_validator[fields0-_v_]", "tests/test_validators.py::test_make_generic_validator[fields1-_v_]", "tests/test_validators.py::test_make_generic_validator[fields2-_v_,_field_]", "tests/test_validators.py::test_make_generic_validator[fields3-_v_,_config_]", "tests/test_validators.py::test_make_generic_validator[fields4-_v_,_values_]", "tests/test_validators.py::test_make_generic_validator[fields5-_v_,_field_,_config_]", "tests/test_validators.py::test_make_generic_validator[fields6-_v_,_field_,_values_]", "tests/test_validators.py::test_make_generic_validator[fields7-_v_,_config_,_values_]", "tests/test_validators.py::test_make_generic_validator[fields8-_v_,_field_,_values_,_config_]", "tests/test_validators.py::test_make_generic_validator[fields9-_cls_,_v_]", "tests/test_validators.py::test_make_generic_validator[fields10-_cls_,_v_]", "tests/test_validators.py::test_make_generic_validator[fields11-_cls_,_v_,_field_]", "tests/test_validators.py::test_make_generic_validator[fields12-_cls_,_v_,_config_]", "tests/test_validators.py::test_make_generic_validator[fields13-_cls_,_v_,_values_]", "tests/test_validators.py::test_make_generic_validator[fields14-_cls_,_v_,_field_,_config_]", "tests/test_validators.py::test_make_generic_validator[fields15-_cls_,_v_,_field_,_values_]", "tests/test_validators.py::test_make_generic_validator[fields16-_cls_,_v_,_config_,_values_]", "tests/test_validators.py::test_make_generic_validator[fields17-_cls_,_v_,_field_,_values_,_config_]", "tests/test_validators.py::test_make_generic_validator_kwargs", "tests/test_validators.py::test_make_generic_validator_invalid", "tests/test_validators.py::test_make_generic_validator_cls_kwargs", "tests/test_validators.py::test_make_generic_validator_cls_invalid", "tests/test_validators.py::test_make_generic_validator_self", "tests/test_validators.py::test_assert_raises_validation_error", "tests/test_validators.py::test_whole", "tests/test_validators.py::test_root_validator", "tests/test_validators.py::test_root_validator_pre", "tests/test_validators.py::test_root_validator_repeat", "tests/test_validators.py::test_root_validator_repeat2", "tests/test_validators.py::test_root_validator_self", "tests/test_validators.py::test_root_validator_extra", "tests/test_validators.py::test_root_validator_types", "tests/test_validators.py::test_root_validator_inheritance", "tests/test_validators.py::test_reuse_global_validators", "tests/test_validators.py::test_allow_reuse[True-True-True-True]", "tests/test_validators.py::test_allow_reuse[True-True-True-False]", "tests/test_validators.py::test_allow_reuse[True-True-False-True]", "tests/test_validators.py::test_allow_reuse[True-True-False-False]", "tests/test_validators.py::test_allow_reuse[True-False-True-True]", "tests/test_validators.py::test_allow_reuse[True-False-True-False]", "tests/test_validators.py::test_allow_reuse[True-False-False-True]", "tests/test_validators.py::test_allow_reuse[True-False-False-False]", "tests/test_validators.py::test_allow_reuse[False-True-True-True]", "tests/test_validators.py::test_allow_reuse[False-True-True-False]", "tests/test_validators.py::test_allow_reuse[False-True-False-True]", "tests/test_validators.py::test_allow_reuse[False-True-False-False]", "tests/test_validators.py::test_allow_reuse[False-False-True-True]", "tests/test_validators.py::test_allow_reuse[False-False-True-False]", "tests/test_validators.py::test_allow_reuse[False-False-False-True]", "tests/test_validators.py::test_allow_reuse[False-False-False-False]", "tests/test_validators.py::test_root_validator_classmethod[True-True]", "tests/test_validators.py::test_root_validator_classmethod[True-False]", "tests/test_validators.py::test_root_validator_classmethod[False-True]", "tests/test_validators.py::test_root_validator_classmethod[False-False]", "tests/test_validators.py::test_root_validator_skip_on_failure" ]
{ "failed_lite_validators": [], "has_test_patch": true, "is_lite": true }
2020-01-17 16:16:07+00:00
mit
4,731
pydantic__pydantic-1175
diff --git a/pydantic/networks.py b/pydantic/networks.py --- a/pydantic/networks.py +++ b/pydantic/networks.py @@ -54,7 +54,7 @@ def url_regex() -> Pattern[str]: if _url_regex_cache is None: _url_regex_cache = re.compile( r'(?:(?P<scheme>[a-z][a-z0-9+\-.]+)://)?' # scheme https://tools.ietf.org/html/rfc3986#appendix-A - r'(?:(?P<user>[^\s:]+)(?::(?P<password>\S*))?@)?' # user info + r'(?:(?P<user>[^\s:/]+)(?::(?P<password>[^\s/]*))?@)?' # user info r'(?:' r'(?P<ipv4>(?:\d{1,3}\.){3}\d{1,3})|' # ipv4 r'(?P<ipv6>\[[A-F0-9]*:[A-F0-9:]+\])|' # ipv6
pydantic/pydantic
0b5ccffc76fb47c41088692a91165cdd404c234e
diff --git a/tests/test_networks.py b/tests/test_networks.py --- a/tests/test_networks.py +++ b/tests/test_networks.py @@ -50,6 +50,7 @@ 'http://андрей@example.com', AnyUrl('https://example.com', scheme='https', host='example.com'), 'https://exam_ple.com/', + 'http://twitter.com/@handle/', ], ) def test_any_url_success(value): @@ -109,11 +110,15 @@ class Model(BaseModel): assert error.get('ctx') == err_ctx, value -def test_any_url_obj(): +def validate_url(s): class Model(BaseModel): v: AnyUrl - url = Model(v='http://example.org').v + return Model(v=s).v + + +def test_any_url_parts(): + url = validate_url('http://example.org') assert str(url) == 'http://example.org' assert repr(url) == "AnyUrl('http://example.org', scheme='http', host='example.org', tld='org', host_type='domain')" assert url.scheme == 'http' @@ -123,53 +128,74 @@ class Model(BaseModel): assert url.port is None assert url == AnyUrl('http://example.org', scheme='https', host='example.org') - url2 = Model(v='http://user:[email protected]:1234/the/path/?query=here#fragment=is;this=bit').v - assert str(url2) == 'http://user:[email protected]:1234/the/path/?query=here#fragment=is;this=bit' - assert repr(url2) == ( + +def test_url_repr(): + url = validate_url('http://user:[email protected]:1234/the/path/?query=here#fragment=is;this=bit') + assert str(url) == 'http://user:[email protected]:1234/the/path/?query=here#fragment=is;this=bit' + assert repr(url) == ( "AnyUrl('http://user:[email protected]:1234/the/path/?query=here#fragment=is;this=bit', " "scheme='http', user='user', password='password', host='example.org', tld='org', host_type='domain', " "port='1234', path='/the/path/', query='query=here', fragment='fragment=is;this=bit')" ) - assert url2.scheme == 'http' - assert url2.user == 'user' - assert url2.password == 'password' - assert url2.host == 'example.org' + assert url.scheme == 'http' + assert url.user == 'user' + assert url.password == 'password' + assert url.host == 'example.org' + assert url.host_type == 'domain' + assert url.port == '1234' + assert url.path == '/the/path/' + assert url.query == 'query=here' + assert url.fragment == 'fragment=is;this=bit' + + +def test_ipv4_port(): + url = validate_url('ftp://123.45.67.8:8329/') + assert url.scheme == 'ftp' + assert url.host == '123.45.67.8' + assert url.host_type == 'ipv4' + assert url.port == '8329' + assert url.user is None + assert url.password is None + + +def test_ipv6_port(): + url = validate_url('wss://[2001:db8::ff00:42]:8329') + assert url.scheme == 'wss' + assert url.host == '[2001:db8::ff00:42]' + assert url.host_type == 'ipv6' + assert url.port == '8329' + + +def test_int_domain(): + url = validate_url('https://£££.org') + assert url.host == 'xn--9aaa.org' + assert url.host_type == 'int_domain' + assert str(url) == 'https://xn--9aaa.org' + + +def test_co_uk(): + url = validate_url('http://example.co.uk') + assert str(url) == 'http://example.co.uk' + assert url.scheme == 'http' + assert url.host == 'example.co.uk' + assert url.tld == 'uk' # wrong but no better solution assert url.host_type == 'domain' - assert url2.port == '1234' - assert url2.path == '/the/path/' - assert url2.query == 'query=here' - assert url2.fragment == 'fragment=is;this=bit' - - url3 = Model(v='ftp://123.45.67.8:8329/').v - assert url3.scheme == 'ftp' - assert url3.host == '123.45.67.8' - assert url3.host_type == 'ipv4' - assert url3.port == '8329' - assert url3.user is None - assert url3.password is None - - url4 = Model(v='wss://[2001:db8::ff00:42]:8329').v - assert url4.scheme == 'wss' - assert url4.host == '[2001:db8::ff00:42]' - assert url4.host_type == 'ipv6' - assert url4.port == '8329' - - url5 = Model(v='https://£££.org').v - assert url5.host == 'xn--9aaa.org' - assert url5.host_type == 'int_domain' - assert str(url5) == 'https://xn--9aaa.org' - - url6 = Model(v='http://example.co.uk').v - assert str(url6) == 'http://example.co.uk' - assert url6.scheme == 'http' - assert url6.host == 'example.co.uk' - assert url6.tld == 'uk' # wrong but no better solution - assert url6.host_type == 'domain' - - url7 = Model(v='http://user:@example.org').v - assert url7.user == 'user' - assert url7.password == '' - assert url7.host == 'example.org' + + +def test_user_no_password(): + url = validate_url('http://user:@example.org') + assert url.user == 'user' + assert url.password == '' + assert url.host == 'example.org' + + +def test_at_in_path(): + url = validate_url('https://twitter.com/@handle') + assert url.scheme == 'https' + assert url.host == 'twitter.com' + assert url.user is None + assert url.password is None + assert url.path == '/@handle' @pytest.mark.parametrize(
Bug in the URL regex used to validate AnyUrl fields # Bug Please complete: * OS: **Ubuntu 18.04** * Python version `import sys; print(sys.version)`: **3.7** * Pydantic version `import pydantic; print(pydantic.VERSION)`: **1.1** **Please read the [docs](https://pydantic-docs.helpmanual.io/) and search through issues to confirm your bug hasn't already been reported.** Where possible please include a self contained code snippet describing your bug: ```py import pydantic class Item(pydantic.Model): url: pydantic.HttpUrl = '' item = Item(url='http://twitter.com/@handle') ``` The above snippet throws an error because of a bug in the `url_regex` used by all `AnyUrl` subclasses that makes the validator think that `twitter.com/` is the username in this URL because of the presence of @ in the path. This can be fixed trivially by adding / to the characters that cannot be in username (or for that matter, password). So in `pydantic/networks.py`, the following line would change from: ``` url_regex = re.compile( r'(?:(?P<scheme>[a-z0-9]+?)://)?' # scheme r'(?:(?P<user>[^\s:]+)(?::(?P<password>\S*))?@)?' # user info r'(?:' r'(?P<ipv4>(?:\d{1,3}\.){3}\d{1,3})|' # ipv4 r'(?P<ipv6>\[[A-F0-9]*:[A-F0-9:]+\])|' # ipv6 r'(?P<domain>[^\s/:?#]+)' # domain, validation occurs later r')?' r'(?::(?P<port>\d+))?' # port r'(?P<path>/[^\s?]*)?' # path r'(?:\?(?P<query>[^\s#]+))?' # query r'(?:#(?P<fragment>\S+))?', # fragment re.IGNORECASE, ) ``` to ``` url_regex = re.compile( r'(?:(?P<scheme>[a-z0-9]+?)://)?' # scheme r'(?:(?P<user>[^\s:/]+)(?::(?P<password>[^\s/]*))?@)?' # user info r'(?:' r'(?P<ipv4>(?:\d{1,3}\.){3}\d{1,3})|' # ipv4 r'(?P<ipv6>\[[A-F0-9]*:[A-F0-9:]+\])|' # ipv6 r'(?P<domain>[^\s/:?#]+)' # domain, validation occurs later r')?' r'(?::(?P<port>\d+))?' # port r'(?P<path>/[^\s?]*)?' # path r'(?:\?(?P<query>[^\s#]+))?' # query r'(?:#(?P<fragment>\S+))?', # fragment re.IGNORECASE, ) ```
0.0
0b5ccffc76fb47c41088692a91165cdd404c234e
[ "tests/test_networks.py::test_at_in_path" ]
[ "tests/test_networks.py::test_any_url_success[http://example.org]", "tests/test_networks.py::test_any_url_success[http://test]", "tests/test_networks.py::test_any_url_success[http://localhost0]", "tests/test_networks.py::test_any_url_success[https://example.org/whatever/next/]", "tests/test_networks.py::test_any_url_success[postgres://user:pass@localhost:5432/app]", "tests/test_networks.py::test_any_url_success[postgres://just-user@localhost:5432/app]", "tests/test_networks.py::test_any_url_success[postgresql+psycopg2://postgres:postgres@localhost:5432/hatch]", "tests/test_networks.py::test_any_url_success[foo-bar://example.org]", "tests/test_networks.py::test_any_url_success[foo.bar://example.org]", "tests/test_networks.py::test_any_url_success[foo0bar://example.org]", "tests/test_networks.py::test_any_url_success[https://example.org]", "tests/test_networks.py::test_any_url_success[http://localhost1]", "tests/test_networks.py::test_any_url_success[http://localhost/]", "tests/test_networks.py::test_any_url_success[http://localhost:8000]", "tests/test_networks.py::test_any_url_success[http://localhost:8000/]", "tests/test_networks.py::test_any_url_success[https://foo_bar.example.com/]", "tests/test_networks.py::test_any_url_success[ftp://example.org]", "tests/test_networks.py::test_any_url_success[ftps://example.org]", "tests/test_networks.py::test_any_url_success[http://example.co.jp]", "tests/test_networks.py::test_any_url_success[http://www.example.com/a%C2%B1b]", "tests/test_networks.py::test_any_url_success[http://www.example.com/~username/]", "tests/test_networks.py::test_any_url_success[http://info.example.com?fred]", "tests/test_networks.py::test_any_url_success[http://info.example.com/?fred]", "tests/test_networks.py::test_any_url_success[http://xn--mgbh0fb.xn--kgbechtv/]", "tests/test_networks.py::test_any_url_success[http://example.com/blue/red%3Fand+green]", "tests/test_networks.py::test_any_url_success[http://www.example.com/?array%5Bkey%5D=value]", "tests/test_networks.py::test_any_url_success[http://xn--rsum-bpad.example.org/]", "tests/test_networks.py::test_any_url_success[http://123.45.67.8/]", "tests/test_networks.py::test_any_url_success[http://123.45.67.8:8329/]", "tests/test_networks.py::test_any_url_success[http://[2001:db8::ff00:42]:8329]", "tests/test_networks.py::test_any_url_success[http://[2001::1]:8329]", "tests/test_networks.py::test_any_url_success[http://[2001:db8::1]/]", "tests/test_networks.py::test_any_url_success[http://www.example.com:8000/foo]", "tests/test_networks.py::test_any_url_success[http://www.cwi.nl:80/%7Eguido/Python.html]", "tests/test_networks.py::test_any_url_success[https://www.python.org/\\u043f\\u0443\\u0442\\u044c]", "tests/test_networks.py::test_any_url_success[http://\\u0430\\u043d\\u0434\\u0440\\u0435\\[email protected]]", "tests/test_networks.py::test_any_url_success[https://example.com]", "tests/test_networks.py::test_any_url_success[https://exam_ple.com/]", "tests/test_networks.py::test_any_url_success[http://twitter.com/@handle/]", "tests/test_networks.py::test_any_url_invalid[http:///example.com/-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https:///example.com/-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://.example.com:8000/foo-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https://example.org\\\\-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https://exampl$e.org-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://??-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://.-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://..-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https://example.org", "tests/test_networks.py::test_any_url_invalid[$https://example.org-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[../icons/logo.gif-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[abc-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[..-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[/-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[+http://example.com/-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[ht*tp://example.com/-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[", "tests/test_networks.py::test_any_url_invalid[-value_error.any_str.min_length-ensure", "tests/test_networks.py::test_any_url_invalid[None-type_error.none.not_allowed-none", "tests/test_networks.py::test_any_url_invalid[http://2001:db8::ff00:42:8329-value_error.url.extra-URL", "tests/test_networks.py::test_any_url_invalid[http://[192.168.1.1]:8329-value_error.url.host-URL", "tests/test_networks.py::test_any_url_parts", "tests/test_networks.py::test_url_repr", "tests/test_networks.py::test_ipv4_port", "tests/test_networks.py::test_ipv6_port", "tests/test_networks.py::test_int_domain", "tests/test_networks.py::test_co_uk", "tests/test_networks.py::test_user_no_password", "tests/test_networks.py::test_http_url_success[http://example.org]", "tests/test_networks.py::test_http_url_success[http://example.org/foobar]", "tests/test_networks.py::test_http_url_success[http://example.org.]", "tests/test_networks.py::test_http_url_success[http://example.org./foobar]", "tests/test_networks.py::test_http_url_success[HTTP://EXAMPLE.ORG]", "tests/test_networks.py::test_http_url_success[https://example.org]", "tests/test_networks.py::test_http_url_success[https://example.org?a=1&b=2]", "tests/test_networks.py::test_http_url_success[https://example.org#a=3;b=3]", "tests/test_networks.py::test_http_url_success[https://foo_bar.example.com/]", "tests/test_networks.py::test_http_url_success[https://exam_ple.com/]", "tests/test_networks.py::test_http_url_invalid[ftp://example.com/-value_error.url.scheme-URL", "tests/test_networks.py::test_http_url_invalid[http://foobar/-value_error.url.host-URL", "tests/test_networks.py::test_http_url_invalid[http://localhost/-value_error.url.host-URL", "tests/test_networks.py::test_http_url_invalid[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-value_error.any_str.max_length-ensure", "tests/test_networks.py::test_coerse_url[", "tests/test_networks.py::test_coerse_url[https://www.example.com-https://www.example.com]", "tests/test_networks.py::test_coerse_url[https://www.\\u0430\\u0440\\u0440\\u04cf\\u0435.com/-https://www.xn--80ak6aa92e.com/]", "tests/test_networks.py::test_coerse_url[https://exampl\\xa3e.org-https://xn--example-gia.org]", "tests/test_networks.py::test_postgres_dsns", "tests/test_networks.py::test_redis_dsns", "tests/test_networks.py::test_custom_schemes", "tests/test_networks.py::test_build_url[kwargs0-ws://[email protected]]", "tests/test_networks.py::test_build_url[kwargs1-ws://foo:[email protected]]", "tests/test_networks.py::test_build_url[kwargs2-ws://example.net?a=b#c=d]", "tests/test_networks.py::test_build_url[kwargs3-http://example.net:1234]", "tests/test_networks.py::test_son", "tests/test_networks.py::test_address_valid[[email protected]@example.com]", "tests/test_networks.py::test_address_valid[[email protected]@muelcolvin.com]", "tests/test_networks.py::test_address_valid[Samuel", "tests/test_networks.py::test_address_valid[foobar", "tests/test_networks.py::test_address_valid[", "tests/test_networks.py::test_address_valid[[email protected]", "tests/test_networks.py::test_address_valid[foo", "tests/test_networks.py::test_address_valid[FOO", "tests/test_networks.py::test_address_valid[<[email protected]>", "tests/test_networks.py::test_address_valid[\\xf1o\\xf1\\[email protected]\\xf1o\\xf1\\xf3-\\xf1o\\xf1\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u6211\\[email protected]\\u6211\\u8cb7-\\u6211\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u7532\\u6590\\u9ed2\\u5ddd\\u65e5\\[email protected]\\u7532\\u6590\\u9ed2\\u5ddd\\u65e5\\u672c-\\u7532\\u6590\\u9ed2\\u5ddd\\u65e5\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u0447\\u0435\\u0431\\u0443\\u0440\\u0430\\u0448\\u043a\\u0430\\u044f\\u0449\\u0438\\u043a-\\u0441-\\u0430\\u043f\\u0435\\u043b\\u044c\\u0441\\u0438\\u043d\\u0430\\u043c\\u0438.\\u0440\\[email protected]\\u0447\\u0435\\u0431\\u0443\\u0440\\u0430\\u0448\\u043a\\u0430\\u044f\\u0449\\u0438\\u043a-\\u0441-\\u0430\\u043f\\u0435\\u043b\\u044c\\u0441\\u0438\\u043d\\u0430\\u043c\\u0438.\\u0440\\u0444-\\u0447\\u0435\\u0431\\u0443\\u0440\\u0430\\u0448\\u043a\\u0430\\u044f\\u0449\\u0438\\u043a-\\u0441-\\u0430\\u043f\\u0435\\u043b\\u044c\\u0441\\u0438\\u043d\\u0430\\u043c\\u0438.\\u0440\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u0909\\u0926\\u093e\\u0939\\u0930\\u0923.\\u092a\\u0930\\u0940\\u0915\\u094d\\[email protected]\\u0909\\u0926\\u093e\\u0939\\u0930\\u0923.\\u092a\\u0930\\u0940\\u0915\\u094d\\u0937-\\u0909\\u0926\\u093e\\u0939\\u0930\\u0923.\\u092a\\u0930\\u0940\\u0915\\u094d\\[email protected]]", "tests/test_networks.py::test_address_valid[[email protected]@example.com]", "tests/test_networks.py::test_address_valid[[email protected]", "tests/test_networks.py::test_address_valid[\\u03b9\\u03c9\\u03ac\\u03bd\\u03bd\\u03b7\\u03c2@\\u03b5\\u03b5\\u03c4\\u03c4.gr-\\u03b9\\u03c9\\u03ac\\u03bd\\u03bd\\u03b7\\u03c2-\\u03b9\\u03c9\\u03ac\\u03bd\\u03bd\\u03b7\\u03c2@\\u03b5\\u03b5\\u03c4\\u03c4.gr]", "tests/test_networks.py::test_address_invalid[f", "tests/test_networks.py::test_address_invalid[foo.bar@exam\\nple.com", "tests/test_networks.py::test_address_invalid[foobar]", "tests/test_networks.py::test_address_invalid[foobar", "tests/test_networks.py::test_address_invalid[@example.com]", "tests/test_networks.py::test_address_invalid[[email protected]]", "tests/test_networks.py::test_address_invalid[[email protected]]", "tests/test_networks.py::test_address_invalid[foo", "tests/test_networks.py::test_address_invalid[foo@[email protected]]", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[\"@example.com0]", "tests/test_networks.py::test_address_invalid[\"@example.com1]", "tests/test_networks.py::test_address_invalid[,@example.com]", "tests/test_networks.py::test_email_str", "tests/test_networks.py::test_name_email" ]
{ "failed_lite_validators": [ "has_hyperlinks" ], "has_test_patch": true, "is_lite": false }
2020-01-17 16:53:40+00:00
mit
4,732
pydantic__pydantic-1183
diff --git a/docs/examples/types_url_punycode.py b/docs/examples/types_url_punycode.py --- a/docs/examples/types_url_punycode.py +++ b/docs/examples/types_url_punycode.py @@ -9,3 +9,6 @@ class MyModel(BaseModel): m2 = MyModel(url='https://www.аррӏе.com/') print(m2.url) print(m2.url.host_type) +m3 = MyModel(url='https://www.example.珠宝/') +print(m3.url) +print(m3.url.host_type) diff --git a/pydantic/networks.py b/pydantic/networks.py --- a/pydantic/networks.py +++ b/pydantic/networks.py @@ -46,7 +46,6 @@ _url_regex_cache = None _ascii_domain_regex_cache = None _int_domain_regex_cache = None -_domain_ending = r'(?P<tld>\.[a-z]{2,63})?\.?' def url_regex() -> Pattern[str]: @@ -73,7 +72,10 @@ def ascii_domain_regex() -> Pattern[str]: global _ascii_domain_regex_cache if _ascii_domain_regex_cache is None: ascii_chunk = r'[_0-9a-z](?:[-_0-9a-z]{0,61}[_0-9a-z])?' - _ascii_domain_regex_cache = re.compile(fr'(?:{ascii_chunk}\.)*?{ascii_chunk}{_domain_ending}', re.IGNORECASE) + ascii_domain_ending = r'(?P<tld>\.[a-z]{2,63})?\.?' + _ascii_domain_regex_cache = re.compile( + fr'(?:{ascii_chunk}\.)*?{ascii_chunk}{ascii_domain_ending}', re.IGNORECASE + ) return _ascii_domain_regex_cache @@ -81,7 +83,8 @@ def int_domain_regex() -> Pattern[str]: global _int_domain_regex_cache if _int_domain_regex_cache is None: int_chunk = r'[_0-9a-\U00040000](?:[-_0-9a-\U00040000]{0,61}[_0-9a-\U00040000])?' - _int_domain_regex_cache = re.compile(fr'(?:{int_chunk}\.)*?{int_chunk}{_domain_ending}', re.IGNORECASE) + int_domain_ending = r'(?P<tld>(\.[^\W\d_]{2,63})|(\.(?:xn--)[_0-9a-z-]{2,63}))?\.?' + _int_domain_regex_cache = re.compile(fr'(?:{int_chunk}\.)*?{int_chunk}{int_domain_ending}', re.IGNORECASE) return _int_domain_regex_cache @@ -220,20 +223,32 @@ def validate_host(cls, parts: Dict[str, str]) -> Tuple[str, Optional[str], str, if host is None: raise errors.UrlHostError() elif host_type == 'domain': + is_international = False d = ascii_domain_regex().fullmatch(host) if d is None: d = int_domain_regex().fullmatch(host) - if not d: + if d is None: raise errors.UrlHostError() - host_type = 'int_domain' - rebuild = True - host = host.encode('idna').decode('ascii') + is_international = True tld = d.group('tld') + if tld is None and not is_international: + d = int_domain_regex().fullmatch(host) + tld = d.group('tld') + is_international = True + if tld is not None: tld = tld[1:] elif cls.tld_required: raise errors.UrlHostTldError() + + if is_international: + host_type = 'int_domain' + rebuild = True + host = host.encode('idna').decode('ascii') + if tld is not None: + tld = tld.encode('idna').decode('ascii') + return host, tld, host_type, rebuild # type: ignore def __repr__(self) -> str:
pydantic/pydantic
4f8f9396906a094626b770fb7cc8eecf03770ffe
Yes, I would. One concern: you might need to wrap the regex in a function to avoid increasing module import time, same as we do for other regexes.
diff --git a/tests/test_networks.py b/tests/test_networks.py --- a/tests/test_networks.py +++ b/tests/test_networks.py @@ -211,6 +211,9 @@ def test_at_in_path(): 'https://example.org#a=3;b=3', 'https://foo_bar.example.com/', 'https://exam_ple.com/', # should perhaps fail? I think it's contrary to the RFC but chrome allows it + 'https://example.xn--p1ai', + 'https://example.xn--vermgensberatung-pwb', + 'https://example.xn--zfr164b', ], ) def test_http_url_success(value): @@ -231,6 +234,8 @@ class Model(BaseModel): ), ('http://foobar/', 'value_error.url.host', 'URL host invalid, top level domain required', None), ('http://localhost/', 'value_error.url.host', 'URL host invalid, top level domain required', None), + ('https://example.123', 'value_error.url.host', 'URL host invalid, top level domain required', None), + ('https://example.ab123', 'value_error.url.host', 'URL host invalid, top level domain required', None), ( 'x' * 2084, 'value_error.any_str.max_length', @@ -260,6 +265,10 @@ class Model(BaseModel): # https://www.xudongz.com/blog/2017/idn-phishing/ accepted but converted ('https://www.аррӏе.com/', 'https://www.xn--80ak6aa92e.com/'), ('https://exampl£e.org', 'https://xn--example-gia.org'), + ('https://example.珠宝', 'https://example.xn--pbt977c'), + ('https://example.vermögensberatung', 'https://example.xn--vermgensberatung-pwb'), + ('https://example.рф', 'https://example.xn--p1ai'), + ('https://exampl£e.珠宝', 'https://xn--example-gia.xn--pbt977c'), ], ) def test_coerse_url(input, output): @@ -269,6 +278,26 @@ class Model(BaseModel): assert Model(v=input).v == output [email protected]( + 'input,output', + [ + (' https://www.example.com \n', 'com'), + (b'https://www.example.com', 'com'), + ('https://www.example.com?param=value', 'com'), + ('https://example.珠宝', 'xn--pbt977c'), + ('https://exampl£e.珠宝', 'xn--pbt977c'), + ('https://example.vermögensberatung', 'xn--vermgensberatung-pwb'), + ('https://example.рф', 'xn--p1ai'), + ('https://example.рф?param=value', 'xn--p1ai'), + ], +) +def test_parses_tld(input, output): + class Model(BaseModel): + v: HttpUrl + + assert Model(v=input).v.tld == output + + def test_postgres_dsns(): class Model(BaseModel): a: PostgresDsn
Support unicode and punycode when validating TLDs # Feature Request Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`: ``` pydantic version: 1.3 pydantic compiled: True install path: /usr/local/lib/python3.8/site-packages/pydantic python version: 3.8.1 (default, Jan 3 2020, 22:55:55) [GCC 8.3.0] platform: Linux-4.9.184-linuxkit-x86_64-with-glibc2.2.5 optional deps. installed: ['typing-extensions'] ``` The IANA has approved many TLDs that are not matched by the [TLD domain ending regex](https://github.com/samuelcolvin/pydantic/blob/07271ca5bc89aff88957274d2de1a06b28dd070c/pydantic/networks.py#L49) used for `HttpUrl` validation. There are currently ~152 such TLDs: see the entries in the [authoritative list of TLDs](http://data.iana.org/TLD/tlds-alpha-by-domain.txt) containing the ASCII Compatible Encoding prefix `xn--`. One approach to adding compatibility for such TLDs would be to modify the domain ending regex pattern to allow for Unicode characters, as well as the corresponding internationalized ASCII strings. For example: ```python _domain_ending = r"(?P<tld>(\.[^\W\d_]{2,63})|(\.(?:xn--)[_0-9a-z-]{2,63}))?\.?" ``` Such a change would allow for the following to run successfully ```python from pydantic import BaseModel, HttpUrl, ValidationError class Domain(BaseModel): domain: HttpUrl ascii_domains = ["https://example.com"] idna_domains = [ "https://example.xn--p1ai", "https://example.xn--vermgensberatung-pwb", "https://example.xn--zfr164b", ] unicode_domains = [str.encode(domain).decode("idna") for domain in idna_domains] valid_domains = ascii_domains + idna_domains + unicode_domains invalid_domains = ["https://example.123", "https://example.ab34"] for domain in valid_domains: Domain(domain=domain) for invalid_domain in invalid_domains: try: Domain(domain=invalid_domain) except ValidationError: pass ``` Would you accept a PR for this?
0.0
4f8f9396906a094626b770fb7cc8eecf03770ffe
[ "tests/test_networks.py::test_http_url_success[https://example.xn--p1ai]", "tests/test_networks.py::test_http_url_success[https://example.xn--vermgensberatung-pwb]", "tests/test_networks.py::test_http_url_success[https://example.xn--zfr164b]", "tests/test_networks.py::test_coerse_url[https://example.\\u73e0\\u5b9d-https://example.xn--pbt977c]", "tests/test_networks.py::test_coerse_url[https://example.verm\\xf6gensberatung-https://example.xn--vermgensberatung-pwb]", "tests/test_networks.py::test_coerse_url[https://example.\\u0440\\u0444-https://example.xn--p1ai]", "tests/test_networks.py::test_coerse_url[https://exampl\\xa3e.\\u73e0\\u5b9d-https://xn--example-gia.xn--pbt977c]", "tests/test_networks.py::test_parses_tld[https://example.\\u73e0\\u5b9d-xn--pbt977c]", "tests/test_networks.py::test_parses_tld[https://exampl\\xa3e.\\u73e0\\u5b9d-xn--pbt977c]", "tests/test_networks.py::test_parses_tld[https://example.verm\\xf6gensberatung-xn--vermgensberatung-pwb]", "tests/test_networks.py::test_parses_tld[https://example.\\u0440\\u0444-xn--p1ai]", "tests/test_networks.py::test_parses_tld[https://example.\\u0440\\u0444?param=value-xn--p1ai]" ]
[ "tests/test_networks.py::test_any_url_success[http://example.org]", "tests/test_networks.py::test_any_url_success[http://test]", "tests/test_networks.py::test_any_url_success[http://localhost0]", "tests/test_networks.py::test_any_url_success[https://example.org/whatever/next/]", "tests/test_networks.py::test_any_url_success[postgres://user:pass@localhost:5432/app]", "tests/test_networks.py::test_any_url_success[postgres://just-user@localhost:5432/app]", "tests/test_networks.py::test_any_url_success[postgresql+psycopg2://postgres:postgres@localhost:5432/hatch]", "tests/test_networks.py::test_any_url_success[foo-bar://example.org]", "tests/test_networks.py::test_any_url_success[foo.bar://example.org]", "tests/test_networks.py::test_any_url_success[foo0bar://example.org]", "tests/test_networks.py::test_any_url_success[https://example.org]", "tests/test_networks.py::test_any_url_success[http://localhost1]", "tests/test_networks.py::test_any_url_success[http://localhost/]", "tests/test_networks.py::test_any_url_success[http://localhost:8000]", "tests/test_networks.py::test_any_url_success[http://localhost:8000/]", "tests/test_networks.py::test_any_url_success[https://foo_bar.example.com/]", "tests/test_networks.py::test_any_url_success[ftp://example.org]", "tests/test_networks.py::test_any_url_success[ftps://example.org]", "tests/test_networks.py::test_any_url_success[http://example.co.jp]", "tests/test_networks.py::test_any_url_success[http://www.example.com/a%C2%B1b]", "tests/test_networks.py::test_any_url_success[http://www.example.com/~username/]", "tests/test_networks.py::test_any_url_success[http://info.example.com?fred]", "tests/test_networks.py::test_any_url_success[http://info.example.com/?fred]", "tests/test_networks.py::test_any_url_success[http://xn--mgbh0fb.xn--kgbechtv/]", "tests/test_networks.py::test_any_url_success[http://example.com/blue/red%3Fand+green]", "tests/test_networks.py::test_any_url_success[http://www.example.com/?array%5Bkey%5D=value]", "tests/test_networks.py::test_any_url_success[http://xn--rsum-bpad.example.org/]", "tests/test_networks.py::test_any_url_success[http://123.45.67.8/]", "tests/test_networks.py::test_any_url_success[http://123.45.67.8:8329/]", "tests/test_networks.py::test_any_url_success[http://[2001:db8::ff00:42]:8329]", "tests/test_networks.py::test_any_url_success[http://[2001::1]:8329]", "tests/test_networks.py::test_any_url_success[http://[2001:db8::1]/]", "tests/test_networks.py::test_any_url_success[http://www.example.com:8000/foo]", "tests/test_networks.py::test_any_url_success[http://www.cwi.nl:80/%7Eguido/Python.html]", "tests/test_networks.py::test_any_url_success[https://www.python.org/\\u043f\\u0443\\u0442\\u044c]", "tests/test_networks.py::test_any_url_success[http://\\u0430\\u043d\\u0434\\u0440\\u0435\\[email protected]]", "tests/test_networks.py::test_any_url_success[https://example.com]", "tests/test_networks.py::test_any_url_success[https://exam_ple.com/]", "tests/test_networks.py::test_any_url_success[http://twitter.com/@handle/]", "tests/test_networks.py::test_any_url_invalid[http:///example.com/-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https:///example.com/-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://.example.com:8000/foo-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https://example.org\\\\-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https://exampl$e.org-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://??-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://.-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[http://..-value_error.url.host-URL", "tests/test_networks.py::test_any_url_invalid[https://example.org", "tests/test_networks.py::test_any_url_invalid[$https://example.org-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[../icons/logo.gif-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[abc-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[..-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[/-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[+http://example.com/-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[ht*tp://example.com/-value_error.url.scheme-invalid", "tests/test_networks.py::test_any_url_invalid[", "tests/test_networks.py::test_any_url_invalid[-value_error.any_str.min_length-ensure", "tests/test_networks.py::test_any_url_invalid[None-type_error.none.not_allowed-none", "tests/test_networks.py::test_any_url_invalid[http://2001:db8::ff00:42:8329-value_error.url.extra-URL", "tests/test_networks.py::test_any_url_invalid[http://[192.168.1.1]:8329-value_error.url.host-URL", "tests/test_networks.py::test_any_url_parts", "tests/test_networks.py::test_url_repr", "tests/test_networks.py::test_ipv4_port", "tests/test_networks.py::test_ipv6_port", "tests/test_networks.py::test_int_domain", "tests/test_networks.py::test_co_uk", "tests/test_networks.py::test_user_no_password", "tests/test_networks.py::test_at_in_path", "tests/test_networks.py::test_http_url_success[http://example.org]", "tests/test_networks.py::test_http_url_success[http://example.org/foobar]", "tests/test_networks.py::test_http_url_success[http://example.org.]", "tests/test_networks.py::test_http_url_success[http://example.org./foobar]", "tests/test_networks.py::test_http_url_success[HTTP://EXAMPLE.ORG]", "tests/test_networks.py::test_http_url_success[https://example.org]", "tests/test_networks.py::test_http_url_success[https://example.org?a=1&b=2]", "tests/test_networks.py::test_http_url_success[https://example.org#a=3;b=3]", "tests/test_networks.py::test_http_url_success[https://foo_bar.example.com/]", "tests/test_networks.py::test_http_url_success[https://exam_ple.com/]", "tests/test_networks.py::test_http_url_invalid[ftp://example.com/-value_error.url.scheme-URL", "tests/test_networks.py::test_http_url_invalid[http://foobar/-value_error.url.host-URL", "tests/test_networks.py::test_http_url_invalid[http://localhost/-value_error.url.host-URL", "tests/test_networks.py::test_http_url_invalid[https://example.123-value_error.url.host-URL", "tests/test_networks.py::test_http_url_invalid[https://example.ab123-value_error.url.host-URL", "tests/test_networks.py::test_http_url_invalid[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-value_error.any_str.max_length-ensure", "tests/test_networks.py::test_coerse_url[", "tests/test_networks.py::test_coerse_url[https://www.example.com-https://www.example.com]", "tests/test_networks.py::test_coerse_url[https://www.\\u0430\\u0440\\u0440\\u04cf\\u0435.com/-https://www.xn--80ak6aa92e.com/]", "tests/test_networks.py::test_coerse_url[https://exampl\\xa3e.org-https://xn--example-gia.org]", "tests/test_networks.py::test_parses_tld[", "tests/test_networks.py::test_parses_tld[https://www.example.com-com]", "tests/test_networks.py::test_parses_tld[https://www.example.com?param=value-com]", "tests/test_networks.py::test_postgres_dsns", "tests/test_networks.py::test_redis_dsns", "tests/test_networks.py::test_custom_schemes", "tests/test_networks.py::test_build_url[kwargs0-ws://[email protected]]", "tests/test_networks.py::test_build_url[kwargs1-ws://foo:[email protected]]", "tests/test_networks.py::test_build_url[kwargs2-ws://example.net?a=b#c=d]", "tests/test_networks.py::test_build_url[kwargs3-http://example.net:1234]", "tests/test_networks.py::test_son", "tests/test_networks.py::test_address_valid[[email protected]@example.com]", "tests/test_networks.py::test_address_valid[[email protected]@muelcolvin.com]", "tests/test_networks.py::test_address_valid[Samuel", "tests/test_networks.py::test_address_valid[foobar", "tests/test_networks.py::test_address_valid[", "tests/test_networks.py::test_address_valid[[email protected]", "tests/test_networks.py::test_address_valid[foo", "tests/test_networks.py::test_address_valid[FOO", "tests/test_networks.py::test_address_valid[<[email protected]>", "tests/test_networks.py::test_address_valid[\\xf1o\\xf1\\[email protected]\\xf1o\\xf1\\xf3-\\xf1o\\xf1\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u6211\\[email protected]\\u6211\\u8cb7-\\u6211\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u7532\\u6590\\u9ed2\\u5ddd\\u65e5\\[email protected]\\u7532\\u6590\\u9ed2\\u5ddd\\u65e5\\u672c-\\u7532\\u6590\\u9ed2\\u5ddd\\u65e5\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u0447\\u0435\\u0431\\u0443\\u0440\\u0430\\u0448\\u043a\\u0430\\u044f\\u0449\\u0438\\u043a-\\u0441-\\u0430\\u043f\\u0435\\u043b\\u044c\\u0441\\u0438\\u043d\\u0430\\u043c\\u0438.\\u0440\\[email protected]\\u0447\\u0435\\u0431\\u0443\\u0440\\u0430\\u0448\\u043a\\u0430\\u044f\\u0449\\u0438\\u043a-\\u0441-\\u0430\\u043f\\u0435\\u043b\\u044c\\u0441\\u0438\\u043d\\u0430\\u043c\\u0438.\\u0440\\u0444-\\u0447\\u0435\\u0431\\u0443\\u0440\\u0430\\u0448\\u043a\\u0430\\u044f\\u0449\\u0438\\u043a-\\u0441-\\u0430\\u043f\\u0435\\u043b\\u044c\\u0441\\u0438\\u043d\\u0430\\u043c\\u0438.\\u0440\\[email protected]]", "tests/test_networks.py::test_address_valid[\\u0909\\u0926\\u093e\\u0939\\u0930\\u0923.\\u092a\\u0930\\u0940\\u0915\\u094d\\[email protected]\\u0909\\u0926\\u093e\\u0939\\u0930\\u0923.\\u092a\\u0930\\u0940\\u0915\\u094d\\u0937-\\u0909\\u0926\\u093e\\u0939\\u0930\\u0923.\\u092a\\u0930\\u0940\\u0915\\u094d\\[email protected]]", "tests/test_networks.py::test_address_valid[[email protected]@example.com]", "tests/test_networks.py::test_address_valid[[email protected]", "tests/test_networks.py::test_address_valid[\\u03b9\\u03c9\\u03ac\\u03bd\\u03bd\\u03b7\\u03c2@\\u03b5\\u03b5\\u03c4\\u03c4.gr-\\u03b9\\u03c9\\u03ac\\u03bd\\u03bd\\u03b7\\u03c2-\\u03b9\\u03c9\\u03ac\\u03bd\\u03bd\\u03b7\\u03c2@\\u03b5\\u03b5\\u03c4\\u03c4.gr]", "tests/test_networks.py::test_address_invalid[f", "tests/test_networks.py::test_address_invalid[foo.bar@exam\\nple.com", "tests/test_networks.py::test_address_invalid[foobar]", "tests/test_networks.py::test_address_invalid[foobar", "tests/test_networks.py::test_address_invalid[@example.com]", "tests/test_networks.py::test_address_invalid[[email protected]]", "tests/test_networks.py::test_address_invalid[[email protected]]", "tests/test_networks.py::test_address_invalid[foo", "tests/test_networks.py::test_address_invalid[foo@[email protected]]", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[", "tests/test_networks.py::test_address_invalid[\\[email protected]]", "tests/test_networks.py::test_address_invalid[\"@example.com0]", "tests/test_networks.py::test_address_invalid[\"@example.com1]", "tests/test_networks.py::test_address_invalid[,@example.com]", "tests/test_networks.py::test_email_str", "tests/test_networks.py::test_name_email" ]
{ "failed_lite_validators": [ "has_hyperlinks", "has_many_modified_files", "has_many_hunks" ], "has_test_patch": true, "is_lite": false }
2020-01-21 01:21:45+00:00
mit
4,733
pydantic__pydantic-1210
diff --git a/docs/examples/models_default_factory.py b/docs/examples/models_default_factory.py new file mode 100644 --- /dev/null +++ b/docs/examples/models_default_factory.py @@ -0,0 +1,9 @@ +from pydantic import BaseModel, Field +from uuid import UUID, uuid4 + +class Model(BaseModel): + uid: UUID = Field(default_factory=uuid4) + +m1 = Model() +m2 = Model() +assert m1.uid != m2.uid diff --git a/pydantic/fields.py b/pydantic/fields.py --- a/pydantic/fields.py +++ b/pydantic/fields.py @@ -1,5 +1,6 @@ import warnings from collections.abc import Iterable as CollectionsIterable +from copy import deepcopy from typing import ( TYPE_CHECKING, Any, @@ -29,6 +30,7 @@ AnyType, Callable, ForwardRef, + NoArgAnyCallable, NoneType, display_as_type, is_literal_type, @@ -67,6 +69,7 @@ class FieldInfo(Representation): __slots__ = ( 'default', + 'default_factory', 'alias', 'alias_priority', 'title', @@ -85,8 +88,9 @@ class FieldInfo(Representation): 'extra', ) - def __init__(self, default: Any, **kwargs: Any) -> None: + def __init__(self, default: Any = Undefined, **kwargs: Any) -> None: self.default = default + self.default_factory = kwargs.pop('default_factory', None) self.alias = kwargs.pop('alias', None) self.alias_priority = kwargs.pop('alias_priority', 2 if self.alias else None) self.title = kwargs.pop('title', None) @@ -106,8 +110,9 @@ def __init__(self, default: Any, **kwargs: Any) -> None: def Field( - default: Any, + default: Any = Undefined, *, + default_factory: Optional[NoArgAnyCallable] = None, alias: str = None, title: str = None, description: str = None, @@ -130,6 +135,8 @@ def Field( :param default: since this is replacing the field’s default, its first argument is used to set the default, use ellipsis (``...``) to indicate the field is required + :param default_factory: callable that will be called when a default value is needed for this field + If both `default` and `default_factory` are set, an error is raised. :param alias: the public name of the field :param title: can be any string, used in the schema :param description: can be any string, used in the schema @@ -152,8 +159,12 @@ def Field( pattern string. The schema will have a ``pattern`` validation keyword :param **extra: any additional keyword arguments will be added as is to the schema """ + if default is not Undefined and default_factory is not None: + raise ValueError('cannot specify both default and default_factory') + return FieldInfo( default, + default_factory=default_factory, alias=alias, title=title, description=description, @@ -208,6 +219,7 @@ class ModelField(Representation): 'pre_validators', 'post_validators', 'default', + 'default_factory', 'required', 'model_config', 'name', @@ -229,6 +241,7 @@ def __init__( class_validators: Optional[Dict[str, Validator]], model_config: Type['BaseConfig'], default: Any = None, + default_factory: Optional[NoArgAnyCallable] = None, required: 'BoolUndefined' = Undefined, alias: str = None, field_info: Optional[FieldInfo] = None, @@ -241,6 +254,7 @@ def __init__( self.outer_type_: Any = type_ self.class_validators = class_validators or {} self.default: Any = default + self.default_factory: Optional[NoArgAnyCallable] = default_factory self.required: 'BoolUndefined' = required self.model_config = model_config self.field_info: FieldInfo = field_info or FieldInfo(default) @@ -257,6 +271,16 @@ def __init__( self.model_config.prepare_field(self) self.prepare() + def get_default(self) -> Any: + if self.default_factory is not None: + value = self.default_factory() + elif self.default is None: + # deepcopy is quite slow on None + value = None + else: + value = deepcopy(self.default) + return value + @classmethod def infer( cls, @@ -272,13 +296,13 @@ def infer( if isinstance(value, FieldInfo): field_info = value - value = field_info.default + value = field_info.default_factory() if field_info.default_factory is not None else field_info.default else: field_info = FieldInfo(value, **field_info_from_config) required: 'BoolUndefined' = Undefined if value is Required: required = True - value = None + field_info.default = None elif value is not Undefined: required = False field_info.alias = field_info.alias or field_info_from_config.get('alias') @@ -288,7 +312,8 @@ def infer( type_=annotation, alias=field_info.alias, class_validators=class_validators, - default=value, + default=field_info.default, + default_factory=field_info.default_factory, required=required, model_config=config, field_info=field_info, @@ -316,8 +341,9 @@ def prepare(self) -> None: Note: this method is **not** idempotent (because _type_analysis is not idempotent), e.g. calling it it multiple times may modify the field and configure it incorrectly. """ - if self.default is not None and self.type_ is None: - self.type_ = type(self.default) + default_value = self.get_default() + if default_value is not None and self.type_ is None: + self.type_ = type(default_value) self.outer_type_ = self.type_ if self.type_ is None: @@ -332,14 +358,14 @@ def prepare(self) -> None: v.always for v in self.class_validators.values() ) - if self.required is False and self.default is None: + if self.required is False and default_value is None: self.allow_none = True self._type_analysis() if self.required is Undefined: self.required = True self.field_info.default = Required - if self.default is Undefined: + if self.default is Undefined and self.default_factory is None: self.default = None self.populate_validators() @@ -726,7 +752,10 @@ def __repr_args__(self) -> 'ReprArgs': args = [('name', self.name), ('type', self._type_display()), ('required', self.required)] if not self.required: - args.append(('default', self.default)) + if self.default_factory is not None: + args.append(('default_factory', f'<function {self.default_factory.__name__}>')) + else: + args.append(('default', self.default)) if self.alt_alias: args.append(('alias', self.alias)) diff --git a/pydantic/main.py b/pydantic/main.py --- a/pydantic/main.py +++ b/pydantic/main.py @@ -853,11 +853,7 @@ def validate_model( # noqa: C901 (ignore complexity) errors.append(ErrorWrapper(MissingError(), loc=field.alias)) continue - if field.default is None: - # deepcopy is quite slow on None - value = None - else: - value = deepcopy(field.default) + value = field.get_default() if not config.validate_all and not field.validate_always: values[name] = value diff --git a/pydantic/typing.py b/pydantic/typing.py --- a/pydantic/typing.py +++ b/pydantic/typing.py @@ -42,11 +42,13 @@ def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Type[ from typing import Callable as Callable AnyCallable = Callable[..., Any] + NoArgAnyCallable = Callable[[], Any] else: from collections.abc import Callable as Callable from typing import Callable as TypingCallable AnyCallable = TypingCallable[..., Any] + NoArgAnyCallable = TypingCallable[[], Any] if sys.version_info < (3, 8): if TYPE_CHECKING: @@ -77,6 +79,7 @@ def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Type[ 'ForwardRef', 'Callable', 'AnyCallable', + 'NoArgAnyCallable', 'AnyType', 'NoneType', 'display_as_type',
pydantic/pydantic
0f948618bab7d36a7ee153f3ad02594b56554e74
I'm hesitant about pseudo types, without reading the docs it's not clear what this does. What we could do is just is the function as the default/initial value? Then unless the type of the field was `Callable` it would call the function to generate a value. This would not be completely backwards, but I think it would be more intuitive. This would work as well! The main idea would be to reduce the amount of boilerplate code required for this type of usage. I think this might be better suited as a keyword argument to Schema (or Field now), or similar. That’s how this functionality is handled by both attrs and dataclasses. > I think this might be better suited as a keyword argument to Schema (or Field now), or similar. That’s how this functionality is handled by both attrs and dataclasses. agreed. #1210 will implement `Field(default_factory=...)`. For use of `ts: datetime = datetime.now` we should wait for v2.
diff --git a/tests/test_main.py b/tests/test_main.py --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,5 +1,6 @@ from enum import Enum -from typing import Any, ClassVar, List, Mapping, Type +from typing import Any, Callable, ClassVar, List, Mapping, Type +from uuid import UUID, uuid4 import pytest @@ -50,6 +51,28 @@ def test_ultra_simple_repr(): assert m.to_string() == 'a=10.2 b=10' +def test_default_dict_repr(): + def myfunc(): + return 1 + + class Model(BaseModel): + a: int = Field(default_factory=myfunc) + b = Field(default_factory=myfunc) + + m = Model() + assert str(m) == 'a=1 b=1' + assert repr(m) == 'Model(a=1, b=1)' + assert ( + repr(m.__fields__['a']) == "ModelField(name='a', type=int, required=False, default_factory='<function myfunc>')" + ) + assert ( + repr(m.__fields__['b']) == "ModelField(name='b', type=int, required=False, default_factory='<function myfunc>')" + ) + assert dict(m) == {'a': 1, 'b': 1} + assert m.dict() == {'a': 1, 'b': 1} + assert m.json() == '{"a": 1, "b": 1}' + + def test_comparing(): m = UltraSimpleModel(a=10.2, b='100') assert m == {'a': 10.2, 'b': 100} @@ -970,3 +993,35 @@ class NewModel(DerivedModel, something=2): something = 1 assert NewModel.something == 2 + + +def test_two_defaults(): + with pytest.raises(ValueError, match='^cannot specify both default and default_factory$'): + + class Model(BaseModel): + a: int = Field(default=3, default_factory=lambda: 3) + + +def test_default_factory(): + class ValueModel(BaseModel): + uid: UUID = uuid4() + + m1 = ValueModel() + m2 = ValueModel() + assert m1.uid == m2.uid + + class DynamicValueModel(BaseModel): + uid: UUID = Field(default_factory=uuid4) + + m1 = DynamicValueModel() + m2 = DynamicValueModel() + assert isinstance(m1.uid, UUID) + assert m1.uid != m2.uid + + # With a callable: we still should be able to set callables as defaults + class FunctionModel(BaseModel): + a: int = 1 + uid: Callable[[], UUID] = Field(uuid4) + + m = FunctionModel() + assert m.uid is uuid4
Simplify setting dynamic default values # Feature Request Please complete: * OS: Windows * Python version 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] * Pydantic version: 0.30 # Feature Request Currently, if I want to have a dynamic default value, it has to be done the following way: ```py from datetime import datetime from pydantic import BaseModel, validator from uuid import UUID, uuid4 class DemoModel(BaseModel): ts: datetime = None id: UUID = None @validator('id', pre=True, always=True) def set_id(cls, v): return v or uuid4() @validator('ts', pre=True, always=True) def set_ts_now(cls, v): return v or datetime.now() ``` This is fine for cases where actual validation has to be provided, however, in many cases like the one portrayed below, this leads to unnecessary code, especially if there are multiple dynamically set values. For instance, a timestamp and an id. It would be great to be able to replace this usage pattern by a pydantic field called `Dynamic` for instance such that one can pass a callable as a default value. This would look like this: ```py from datetime import datetime from uuid import UUID, uuid4 from pydantic import BaseModel, validator, Dynamic class DemoModel(BaseModel): ts: Dynamic[datetime] = datetime.now id: Dynamic[UUID] = uuid4 ``` I don't expect that this would need to modify any existing functionalities. Probably just a need to create some sort of wrapper.
0.0
0f948618bab7d36a7ee153f3ad02594b56554e74
[ "tests/test_main.py::test_default_dict_repr", "tests/test_main.py::test_two_defaults", "tests/test_main.py::test_default_factory" ]
[ "tests/test_main.py::test_success", "tests/test_main.py::test_ultra_simple_missing", "tests/test_main.py::test_ultra_simple_failed", "tests/test_main.py::test_comparing", "tests/test_main.py::test_nullable_strings_success", "tests/test_main.py::test_nullable_strings_fails", "tests/test_main.py::test_recursion", "tests/test_main.py::test_recursion_fails", "tests/test_main.py::test_not_required", "tests/test_main.py::test_infer_type", "tests/test_main.py::test_allow_extra", "tests/test_main.py::test_forbidden_extra_success", "tests/test_main.py::test_forbidden_extra_fails", "tests/test_main.py::test_disallow_mutation", "tests/test_main.py::test_extra_allowed", "tests/test_main.py::test_extra_ignored", "tests/test_main.py::test_set_attr", "tests/test_main.py::test_set_attr_invalid", "tests/test_main.py::test_any", "tests/test_main.py::test_alias", "tests/test_main.py::test_population_by_field_name", "tests/test_main.py::test_field_order", "tests/test_main.py::test_required", "tests/test_main.py::test_not_immutability", "tests/test_main.py::test_immutability", "tests/test_main.py::test_const_validates", "tests/test_main.py::test_const_uses_default", "tests/test_main.py::test_const_with_wrong_value", "tests/test_main.py::test_const_list", "tests/test_main.py::test_const_list_with_wrong_value", "tests/test_main.py::test_const_validation_json_serializable", "tests/test_main.py::test_validating_assignment_pass", "tests/test_main.py::test_validating_assignment_fail", "tests/test_main.py::test_enum_values", "tests/test_main.py::test_enum_raw", "tests/test_main.py::test_set_tuple_values", "tests/test_main.py::test_default_copy", "tests/test_main.py::test_arbitrary_type_allowed_validation_success", "tests/test_main.py::test_arbitrary_type_allowed_validation_fails", "tests/test_main.py::test_arbitrary_types_not_allowed", "tests/test_main.py::test_type_type_validation_success", "tests/test_main.py::test_type_type_subclass_validation_success", "tests/test_main.py::test_type_type_validation_fails_for_instance", "tests/test_main.py::test_type_type_validation_fails_for_basic_type", "tests/test_main.py::test_annotation_field_name_shadows_attribute", "tests/test_main.py::test_value_field_name_shadows_attribute", "tests/test_main.py::test_class_var", "tests/test_main.py::test_fields_set", "tests/test_main.py::test_exclude_unset_dict", "tests/test_main.py::test_exclude_unset_recursive", "tests/test_main.py::test_dict_exclude_unset_populated_by_alias", "tests/test_main.py::test_dict_exclude_unset_populated_by_alias_with_extra", "tests/test_main.py::test_dir_fields", "tests/test_main.py::test_dict_with_extra_keys", "tests/test_main.py::test_root", "tests/test_main.py::test_root_list", "tests/test_main.py::test_root_failed", "tests/test_main.py::test_root_undefined_failed", "tests/test_main.py::test_parse_root_as_mapping", "tests/test_main.py::test_parse_obj_non_mapping_root", "tests/test_main.py::test_untouched_types", "tests/test_main.py::test_custom_types_fail_without_keep_untouched", "tests/test_main.py::test_model_iteration", "tests/test_main.py::test_custom_init_subclass_params" ]
{ "failed_lite_validators": [ "has_added_files", "has_many_modified_files", "has_many_hunks", "has_pytest_match_arg" ], "has_test_patch": true, "is_lite": false }
2020-02-06 01:13:27+00:00
mit
4,734