Python Usign Selenium的明显缺陷:PosixPath的问题

Python Usign Selenium的明显缺陷:PosixPath的问题,python,python-3.x,django,selenium,posix,Python,Python 3.x,Django,Selenium,Posix,晚上好,, 我使用Python3.7和Django3.1.5启动了一个django项目 当我启动单一测试时,它们运行得非常完美。 运行selenium时,我得到的是: File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 137, in run self.result = application(self.environ, s

晚上好,, 我使用Python3.7和Django3.1.5启动了一个django项目 当我启动单一测试时,它们运行得非常完美。 运行selenium时,我得到的是:

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/test/testcases.py", line 1322, in __call__
    return super().__call__(environ, start_response)
  File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
    response = self.get_response(request)
  File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/test/testcases.py", line 1305, in get_response
    return self.serve(request)
  File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/test/testcases.py", line 1317, in serve
    return serve(request, final_rel_path, document_root=self.get_base_dir())
  File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/views/static.py", line 36, in serve
    fullpath = Path(safe_join(document_root, path))
  File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/utils/_os.py", line 17, in safe_join
    final_path = abspath(join(base, *paths))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/posixpath.py", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
奇怪的是:

  • 没有引发与我的项目链接的错误
  • Selenium测试完全通过,以下是我的Selenium设置:
因此,我可以继续我的项目,然而,这个令人困惑的问题困扰着我。 如果你们中有人能给我一个暗示,我会非常高兴的。
亲切问候。

这就是重点。添加:

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
我的设置解决了这个问题。
Thx.

看起来您的静态根目录没有定义,但您正在URL.py中使用
django.contrib.staticfiles.views.STATIC
STATIC_ROOT = os.path.join(BASE_DIR, 'static')