microsoft / microsoft/playwright-pytest

Make pytest-base-url optional to avoid transitive MPL-2.0 dependency (certifi)

Open
#311 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
563
Forks
90
Avg merge
11m
Merged PRs (30d)
1

Description

pytest-playwright has a hard dependency on pytest-base-url (declared in pyproject.toml):

dependencies = [
"playwright>=1.18",
"pytest>=6.2.4,<10.0.0",
"pytest-base-url>=1.0.0,<3.0.0", # <-- hard requirement
"python-slugify>=6.0.0,<9.0.0",
]

This creates a transitive dependency chain:

pytest-playwright → pytest-base-url → requests → certifi (MPL-2.0)

certifi is licensed under MPL 2.0, which triggers license compliance flags in enterprise security scanners (Snyk, Black Duck, FOSSA). MPL 2.0 has copyleft provisions — modified files must be released under
the same license. Many enterprise organizations have policies that flag or block MPL-2.0 dependencies.

Impact

Teams in regulated/enterprise environments cannot use pytest-playwright without either:

  • Getting a legal exception for MPL-2.0 (often a lengthy process)
  • Building custom Playwright pytest fixtures from scratch to avoid the dependency (what we had to do)

Suggestion

Make pytest-base-url an optional dependency rather than a hard requirement:

[project]
dependencies = [
"playwright>=1.18",
"pytest>=6.2.4,<10.0.0",
"python-slugify>=6.0.0,<9.0.0",
]

[project.optional-dependencies]
base-url = ["pytest-base-url>=1.0.0,<3.0.0"]

Then in the plugin code, make the base_url fixture conditional:

try:
from pytest_base_url.plugin import base_url # noqa: F401
except ImportError:
@pytest.fixture
def base_url():
return None

Most users set baseURL in playwright.config or browser.new_context(base_url=...) directly. The pytest-base-url integration (which reads from --base-url CLI flag or base_url config) is a convenience, not a
core requirement.

Dependency Chain Detail

┌───────────────────┬────────────┬────────────┬──────────────────────────────────┐
│ Package │ Version │ License │ Role │
├───────────────────┼────────────┼────────────┼──────────────────────────────────┤
│ pytest-playwright │ 0.7.2 │ Apache-2.0 │ Direct │
├───────────────────┼────────────┼────────────┼──────────────────────────────────┤
│ pytest-base-url │ 2.1.0 │ MPL-2.0 │ Transitive │
├───────────────────┼────────────┼────────────┼──────────────────────────────────┤
│ requests │ 2.32.5 │ Apache-2.0 │ Transitive (via pytest-base-url) │
├───────────────────┼────────────┼────────────┼──────────────────────────────────┤
│ certifi │ 2024.12.14 │ MPL-2.0 │ Transitive (via requests) │
└───────────────────┴────────────┴────────────┴──────────────────────────────────┘

Environment

  • pytest-playwright 0.7.2
  • Python 3.13
  • Snyk security scanner (enterprise policy flags MPL-2.0)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review pyproject.toml and the plugin code that imports or exposes pytest-base-url integration. Check how the existing test suite exercises base_url and dependency installation. Done means the core package installs without pytest-base-url, the base_url fixture remains safe when it is absent, and the optional integration still works when installed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.