from app.functions import sum
def test_sum():
assert add(1, 10) == 11
def add(a, b):
return a + b
$ pip3 install pipenv
Installing collected packages: virtualenv
WARNING: Failed to write executable - trying to use .deleteme logic
ERROR: Could not install packages due to an OSError: [WinError 2] 系统找不到指定的文件。: 'C:\\Python310\\Scripts\\virtualenv.exe' -> 'C:\\Python310\\Scripts\\virtualenv.exe.deleteme'
#尝试
pip3 install pipenv --user
Requirement already satisfied: pipenv in c:\python310\lib\site-packages (2021.11.23)
Requirement already satisfied: setuptools>=36.2.1 in c:\python310\lib\site-packages (from pipenv) (57.4.0)
Requirement already satisfied: pip>=18.0 in c:\users\xh\appdata\roaming\python\python310\site-packages (from pipenv) (21.3.1)
Requirement already satisfied: virtualenv-clone>=0.2.5 in c:\python310\lib\site-packages (from pipenv) (0.5.7)
Requirement already satisfied: certifi in c:\users\xh\appdata\roaming\python\python310\site-packages (from pipenv) (2021.10.8)
Requirement already satisfied: virtualenv in c:\python310\lib\site-packages (from pipenv) (20.10.0)
Requirement already satisfied: six<2,>=1.9.0 in c:\python310\lib\site-packages (from virtualenv->pipenv) (1.16.0)
Requirement already satisfied: distlib<1,>=0.3.1 in c:\python310\lib\site-packages (from virtualenv->pipenv) (0.3.4)
Requirement already satisfied: backports.entry-points-selectable>=1.0.4 in c:\python310\lib\site-packages (from
virtualenv->pipenv) (1.1.1)
Requirement already satisfied: filelock<4,>=3.2 in c:\python310\lib\site-packages (from virtualenv->pipenv) (3.4.0)
Requirement already satisfied: platformdirs<3,>=2 in c:\python310\lib\site-packages (from virtualenv->pipenv) (2.4.0)
$ pipenv
bash: pipenv: command not found
#尝试
$ python -m pipenv
#安装pytest
$ python -m pipenv install pytest
Creating a virtualenv for this project...
Pipfile: D:\gitlab\Pipfile
Using C:/Python310/python.exe (3.10.0) to create virtualenv...
[ =] Creating virtual environment...created virtual environment CPython3.10.0.final.0-64 in 6580ms
creator CPython3Windows(dest=C:\Users\XH\.virtualenvs\gitlab-DBb610So, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\XH\AppData\Local\pypa\virtualenv)
added seed packages: pip==21.3.1, setuptools==58.3.0, wheel==0.37.0
activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Successfully created virtual environment!
Virtualenv location: C:\Users\XH\.virtualenvs\gitlab-DBb610So
Creating a Pipfile for this project...
Installing pytest...
Adding pytest to Pipfile's [packages]...
Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
Success!
Updated Pipfile.lock (99a583)!
Installing dependencies from Pipfile.lock (99a583)...
================================ 0/0 - 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
$ python -m pipenv shell
Launching subshell in virtual environment...
clear
$ python -m pytest
============================================= test session starts =============================================
platform win32 -- Python 3.10.0, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: D:\gitlab\gitlab_example_en
collected 0 items / 1 error
=================================================== ERRORS ====================================================
__________________________________ ERROR collecting tests/test_functions.py ___________________________________
ImportError while importing test module 'D:\gitlab\gitlab_example_en\tests\test_functions.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\Python310\lib\importlib\__init__.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests\test_functions.py:1: in <module>
from app.functions import sum
E ImportError: cannot import name 'sum' from 'app.functions' (D:\gitlab\gitlab_example_en\app\functions.py)
=========================================== short test summary info ===========================================
ERROR tests/test_functions.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================== 1 error in 0.14s ===============================================
$ docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner:alpine-v14.4.2 register
Runtime platform arch=amd64 os=linux pid=7 revision=50fc80a6 version=14.4.2
Running in system-mode.
Enter the GitLab instance URL (for example, https://gitlab.com/):
http://192.168.211.70:8081
Enter the registration token:
6D5mo8iWCLBaVdqcaqjN
Enter a description for the runner:
[329b671ffa00]: gitlab-example
Enter tags for the runner (comma-separated):
Registering runner... succeeded runner=6D5mo8iW
Enter an executor: ssh, virtualbox, docker+machine, shell, docker-ssh+machine, kubernetes, custom, docker, docker-ssh, parallels:
docker
Enter the default Docker image (for example, ruby:2.6):
ubuntu:20.04
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!