Skip to content

Commit

Permalink
Add objwrapper test
Browse files Browse the repository at this point in the history
  • Loading branch information
杨赫然 committed Oct 25, 2024
1 parent 781bb53 commit dc98b4c
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ci/install-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e -x

SCRIPT=${BASH_SOURCE[0]}
TESTS_DIR=$(dirname "${SCRIPT}")/..
SETUP_DIR=${TESTS_DIR}/ci

cd $SETUP_DIR

pip install -r requirements.txt
4 changes: 4 additions & 0 deletions ci/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
termcolor>=2.3.0
requests>=2.31.0
pytest>=7.4.0
pytest-instafail
18 changes: 18 additions & 0 deletions ci/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python3

import os

from utils import setup_logging, shell
from os.path import abspath, join

TOPDIR = abspath(join(os.getcwd()))


def main():
shell("py.test", env=dict(os.environ))



if __name__ == "__main__":
setup_logging()
main()
50 changes: 50 additions & 0 deletions ci/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import os
import logging
from subprocess import PIPE, CalledProcessError, Popen
import sys

import termcolor


logger = logging.getLogger(__name__)


def setup_logging():
kw = {
"format": "[%(asctime)s][%(module)s]: %(message)s",
"datefmt": "%m/%d/%Y %H:%M:%S",
"level": logging.DEBUG,
"stream": sys.stdout,
}

logging.basicConfig(**kw)
logging.getLogger("requests.packages.urllib3.connectionpool").setLevel(
logging.WARNING
)


def shell(cmd, inputdata=None, wait=True, **kw):
info('calling "%s" in %s', cmd, kw.get("cwd", os.getcwd()))
kw["shell"] = not isinstance(cmd, list)
kw["stdin"] = PIPE if inputdata else None
p = Popen(cmd, **kw)
if inputdata:
p.communicate(inputdata)
if wait:
p.wait()
if p.returncode:
raise CalledProcessError(p.returncode, cmd)
else:
return p


def info(fmt, *a):
logger.info(green(fmt), *a)


def green(s):
return _color(s, "green")


def _color(s, color):
return s if not os.isatty(sys.stdout.fileno()) else termcolor.colored(str(s), color)

0 comments on commit dc98b4c

Please sign in to comment.