This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from wordcount.cli import cli | |
from wordcount.gui import gui | |
if len(sys.argv) >= 2: | |
cli() | |
else: | |
gui() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from abc import ABC, abstractmethod | |
class Animal(ABC): | |
@abstractmethod | |
def emit_sound(self): | |
pass | |
@abstractmethod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Write a function that determines if all alpha characters in a string | |
are surrounded (the characters immediately before and after) by a plus sign. | |
Function should return false if any alpha character present in the string isn't | |
surrounded by a plus sign. Otherwise the function should return true. | |
""" | |
def symbols(input_str: str) -> bool: | |
"""Fill your code bellow to make all tests pass.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from requests_futures.sessions import FuturesSession | |
def response_for_urls(urls): | |
"""Asynchronously get response for many urls.""" | |
with FuturesSession() as session: | |
futures = [ | |
session.get(url) for url in urls | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from decimal import Decimal, ROUND_HALF_UP | |
class Money(Decimal): | |
def __new__(cls, value=0, decimal_precision=2): | |
number = super().__new__(cls, value) | |
if not number._is_precise(decimal_precision): | |
number = number._round(decimal_precision) | |
return number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from requests.auth import AuthBase | |
class EduzzAuth(AuthBase): | |
AUTH_PATH = "/credential/generate_token" | |
TOKEN_EXPIRED_ERROR_CODE = "#0029" | |
def __init__(self, email, publickey, apikey, session_class): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/betapp/betapp/greyhound/utils/racingpost.py b/betapp/betapp/greyhound/utils/racingpost.py | |
index db9da89..4f976f1 100644 | |
--- a/betapp/betapp/greyhound/utils/racingpost.py | |
+++ b/betapp/betapp/greyhound/utils/racingpost.py | |
@@ -4,7 +4,7 @@ import requests | |
from dataclasses import dataclass | |
from dateutil import tz | |
-from typing import List | |
+from typing import List, get_type_hints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_session_uses_custom_json_decoder(httpretty): | |
httpretty.register_uri( | |
httpretty.GET, URL, serialize({"datetime": datetime(2021, 12, 4)}) | |
) | |
response = EduzzSession().get("/") | |
data = response.json() | |
assert isinstance(data["datetime"], datetime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
@pytest.fixture | |
def httpretty(allow_net_connect=False, verbose=False): | |
import httpretty | |
httpretty.reset() | |
httpretty.enable(allow_net_connect=allow_net_connect, verbose=verbose) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
class IntervalMap: | |
def __init__(self): | |
self.limits = [] | |
self.map = {} | |
def __setitem__(self, upper_bound, value): | |
self.limits.append(upper_bound) |
NewerOlder