我无法通过容器中的端口连接到django.我正在使用这个地址:0.0.0.0 . :8000,请参阅:http://joxi.ru/Dr8MeGLhkBWnLm .我正在用一个命令创建一个图像和一个容器:'docker-compose up -d'.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4fea50856eef docker_web "python manage.py ru…" 13 seconds ago Up 11 seconds 0.0.0.0:8000->8000/tcp docker_web_1
Run Code Online (Sandbox Code Playgroud)
泊坞窗,compose.yaml
version: '3'
services:
web:
build:
context: .
dockerfile: /django.testsite/Dockerfile
ports:
- "8000:8000"
Run Code Online (Sandbox Code Playgroud)
Dockerfile
FROM python:3
RUN easy_install pip
RUN pip install django==1.9.12
RUN pip install requests
ADD . /.
WORKDIR /django.testsite
CMD ["python", "manage.py", "runserver", "8000"]
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我正准备与验证器一起开放的PR,因此正在修改造假者,并且希望能够测试我将拥有的新依赖项。
setup(
name='Faker',
...
install_requires=[
"python-dateutil>=2.4",
"six>=1.10",
"text-unidecode==1.2",
],
tests_require=[
"validators@https://github.com/kingbuzzman/validators/archive/0.13.0.tar.gz#egg=validators-0.13.0", # TODO: this will change # noqa
"ukpostcodeparser>=1.1.1",
...
],
...
)
Run Code Online (Sandbox Code Playgroud)
python setup.py test 拒绝安装0.13.0版本。
如果我将故障线向上移动install_requires=[..](应该不存在)
setup(
name='Faker',
...
install_requires=[
"python-dateutil>=2.4",
"six>=1.10",
"text-unidecode==1.2",
"validators@https://github.com/kingbuzzman/validators/archive/0.13.0.tar.gz#egg=validators-0.13.0", # TODO: this will change # noqa
],
tests_require=[
"ukpostcodeparser>=1.1.1",
...
],
...
)
Run Code Online (Sandbox Code Playgroud)
pip install -e .一切都很好-安装了正确的版本。python setup.py develop相同的问题。My guess is setuptools/distutils doing something weird -- pip seems to …
寻找 SSH 所需的步骤colima,这太新了,而且文档有点稀缺。我需要复制这些卷,而运行scp似乎是理想的选择。
我里面有以下内容conftest.py
@pytest.mark.django_db
@pytest.fixture(scope='module')
def thing():
print('sleeping') # represents a very expensive function that i want to only ever once once per module
Thing.objects.create(thing='hello')
Thing.objects.create(thing='hello')
Thing.objects.create(thing='hello')
Run Code Online (Sandbox Code Playgroud)
里面tests.py
@pytest.mark.django_db
def test_thing(thing):
assert models.Thing.objects.count() > 1
@pytest.mark.django_db
def test_thing2(thing):
assert models.Thing.objects.count() > 1
@pytest.mark.django_db
@pytest.mark.usefixtures('thing')
def test_thing3():
assert models.Thing.objects.count() > 1
Run Code Online (Sandbox Code Playgroud)
所有三个测试都会抛出相同的错误:RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it.
我尝试过使用scope='session'///scope='class'scope='package'scope='module'唯一有效的方法是`scope='function',它违背了我想要实现的目的我希望能够为每个模块创建一次所有这些项目,而不是每次测试一次。
注意:我在大型代码库中遇到了这个问题,并使用单个应用程序创建了一个新的 django 项目来测试并查看问题是否是现有的测试代码,并且在独立测试中也失败了。使用 …