Skip to content

Commit

Permalink
update test workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
voidZXL committed Nov 18, 2024
1 parent 735baf5 commit 4506b0f
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 101 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ jobs:
python-version: "3.13"
django-version: "5.1"
name: "3.13 on Linux"
- os: windows-latest
python-version: "3.13"
django-version: "5.1"
name: "3.13 on Windows"
- os: macos-latest
python-version: "3.13"
django-version: "5.1"
name: "3.13 on Mac"
# - os: windows-latest
# python-version: "3.13"
# django-version: "5.1"
# name: "3.13 on Windows"
# - os: macos-latest
# python-version: "3.13"
# django-version: "5.1"
# name: "3.13 on Mac"
- os: ubuntu-latest
python-version: "3.11"
django-version: "5.0"
name: "3.11 (django 5.0)"
- os: ubuntu-latest
python-version: "3.11"
python-version: "3.10"
django-version: "4.2"
name: "3.10 (django 4.2)"
- os: ubuntu-latest
python-version: "3.9"
django-version: "4.1"
name: "3.11 (django 4.1)"
name: "3.9 (django 4.1)"
- os: ubuntu-latest
python-version: "3.8"
django-version: "4.0"
name: "3.8 (django 4.0)"
- os: ubuntu-latest
python-version: "3.13"
django-version: "4.1"
name: "3.13 (django 4.1)"

name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
Expand Down
7 changes: 7 additions & 0 deletions tests/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
# import sanic
import sys

try:
from sanic import Sanic
Sanic._app_registry = {}
# clear sanic registry
except ImportError:
pass


class ServiceEnvironment(Env):
PRODUCTION: bool = False
Expand Down
8 changes: 4 additions & 4 deletions tests/test_4_client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ async def process_response(self, response: Response):

def test_request_failure(self, sync_request_backend):
with TestClient(
base_url='http://0:0',
base_url='http://127.0.0.1:1',
backend=sync_request_backend,
default_timeout=0.5
) as client:
with pytest.raises(Exception):
client.get_doc(category='test')

with TestClient(
base_url='http://0:0',
base_url='http://127.0.0.1:1',
backend=sync_request_backend,
default_timeout=0.5,
fail_silently=True
Expand All @@ -273,15 +273,15 @@ def test_request_failure(self, sync_request_backend):
@pytest.mark.asyncio
async def test_async_request_failure(self, async_request_backend):
with TestClient(
base_url='http://127.0.0.1:0',
base_url='http://127.0.0.1:1',
backend=async_request_backend,
default_timeout=0.5
) as client:
with pytest.raises(Exception):
await client.aget_doc(category='test')

with TestClient(
base_url='http://127.0.0.1:0',
base_url='http://127.0.0.1:1',
backend=async_request_backend,
default_timeout=0.5,
fail_silently=True
Expand Down
77 changes: 0 additions & 77 deletions tests/test_5_servers/test_backend.py

This file was deleted.

1 change: 1 addition & 0 deletions tests/test_7_ops/sanic_site/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from sanic import Sanic
from sanic.response import text
Sanic._app_registry = {}

app = Sanic('MyTestApp')

Expand Down
9 changes: 6 additions & 3 deletions utilmeta/ops/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,15 @@ def get_sys_metrics(self):
open_files = len(process.open_files())
except psutil.Error:
open_files = 0

try:
net_connections = getattr(process, 'net_connections', getattr(process, 'connections'))()
except (psutil.Error, AttributeError):
net_connections = []
return dict(
used_memory=getattr(mem_info, 'uss', getattr(mem_info, 'rss')),
memory_info={f: getattr(mem_info, f) for f in getattr(mem_info, '_fields')},
total_net_connections=len(process.connections()),
active_net_connections=len([c for c in process.connections() if c.status != 'CLOSE_WAIT']),
total_net_connections=len(net_connections),
active_net_connections=len([c for c in net_connections if c.status != 'CLOSE_WAIT']),
file_descriptors=process.num_fds() if psutil.POSIX else None,
cpu_percent=process.cpu_percent(interval=1),
memory_percent=round(process.memory_percent('uss'), 2),
Expand Down
2 changes: 1 addition & 1 deletion utilmeta/utils/constant/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Reg(Static):
# '!-ZS-\x7f]|\\[\x01-\t\x0b\x0c\x0e-\x7f])+)\\])&'
EMAIL_ALNUM = '^[a-zA-Z0-9]+@[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)+[a-z0-9A-Z]+$'
EMAIL = '^[a-z0-9A-Z]+[a-z0-9A-Z._-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+[a-z0-9A-Z]+$'
EMAIL_SIMPLE = '^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$'
EMAIL_SIMPLE = r"^\S+@\S+\.\S+$"

must_contains_letter_number = '(?=.*[0-9])(?=.*[a-zA-Z]).+'
must_contains_letter_number_special = r'(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).+'
Expand Down
2 changes: 1 addition & 1 deletion utilmeta/utils/functional/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@


def normalize_title(title: str):
return ' '.join(re.sub('\s', ' ', title).split())
return ' '.join(re.sub(r'\s', ' ', title).split())


def _list_dict(val):
Expand Down
4 changes: 3 additions & 1 deletion utilmeta/utils/functional/sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,12 @@ def load_ini(content: str, parse_key: bool = False) -> dict:
annotate = line.split()[0].startswith('#') or line.split()[0].startswith(';')
if annotate:
continue
if re.fullmatch(r'\\[(.*?)\\]', line):
if re.fullmatch(r'\[(.*?)\]', line):
key = line.strip('[]')
ini[key] = dic = {}
else:
if '=' not in line:
continue
from utype import TypeTransformer
key, val = line.split('=')
if parse_key:
Expand Down

0 comments on commit 4506b0f

Please sign in to comment.