potassco / potassco/constraint-handler

Order-dependent test failures: custom_globals.lp mutates global Python evaluation environment (_shared_environment) and leaks across tests

Open
#188 0 comments 0 reactions 2 assignees View on GitHub

@VictosVertex is already working on this.

Since Mar 16, 2026.

Dominant language
Python
Stars
3
Forks
0
Avg merge
1d 19h
Merged PRs (30d)
20

Description

Running the full test suite via nox -s test can produce order-dependent failures in tests that use Python operators like python("math.pow"). The root cause is that custom_globals.lp deliberately modifies the global/shared Python evaluation environment in constraint_handler.evaluator (specifically _shared_environment) and that change persists for the remainder of the pytest process.

Because the Python helper code used by @pythonEvalExpr / Python operators reads globals from constraint_handler.evaluator._shared_environment, mutating it in one test affects unrelated subsequent tests. This makes the suite sensitive to test order and can cause flaky failures.

Steps to reproduce

Run the full suite:
nox -s test
Observe that after custom_globals runs, a later test that relies on math being present in the Python environment may fail (e.g., a fixture using operation(python("math.pow"), ...)).

Related to #72

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.