Skip to content

Commit 3f6c7ba

Browse files
committed
Fix config parsing bugs and unskip 3 passing tests
- Fix empty string parsing in version-overrides and ignores - Fix line.strip() not being assigned in ignores parsing - Fix test_resolve_dependencies_simple_file assertion - Fix test_write_output_with_ignores to use read() - Fix test_write_relative_constraints_path_different_dirs to include constraints All tests now pass (177 passed, 4 skipped)
1 parent 8f6e558 commit 3f6c7ba

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
- Fix #65: Check source directories exist before writing to requirements-mxdev.txt. In **offline mode**: missing sources log WARNING and are written as comments (expected behavior). In **non-offline mode**: missing sources log ERROR and mxdev exits with RuntimeError (fatal error indicating checkout failure). This fixes mxmake two-stage installation workflow and prevents silent failures when sources fail to check out.
66
[jensens]
7+
- Fix: Configuration parsing no longer logs "Can not parse override:" errors when `version-overrides` is empty. Empty lines in `version-overrides` and `ignores` are now properly skipped during parsing. Also fixed bug where `ignores` lines were not properly stripped of whitespace.
8+
[jensens]
9+
- Fix: Three tests that were accidentally marked as skipped during PR #66 merge are now fixed and passing: `test_resolve_dependencies_simple_file` (fixed assertion to check line contents), `test_write_output_with_ignores` (fixed to use read() for proper ignore processing), and `test_write_relative_constraints_path_different_dirs` (fixed to include constraints content).
10+
[jensens]
711
- Fix: Add 'synchronize' event to pull_request workflow triggers. This ensures CI runs when PRs are updated with new commits (e.g., after rebasing or pushing new changes), not just when opened or reopened.
812
[jensens]
913
- Chore: Optimize GitHub Actions to prevent duplicate workflow runs on pull requests. Restrict `push` trigger to only run on `main` branch, so PRs only trigger via `pull_request` event. This reduces CI resource usage by 50% for PR workflows.

src/mxdev/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ def __init__(
7171
raw_overrides = settings.get("version-overrides", "").strip()
7272
self.overrides = {}
7373
for line in raw_overrides.split("\n"):
74+
line = line.strip()
75+
if not line:
76+
continue
7477
try:
7578
parsed = Requirement(line)
7679
except Exception:
@@ -81,7 +84,7 @@ def __init__(
8184
raw_ignores = settings.get("ignores", "").strip()
8285
self.ignore_keys = []
8386
for line in raw_ignores.split("\n"):
84-
line.strip()
87+
line = line.strip()
8588
if line:
8689
self.ignore_keys.append(line)
8790

tests/test_processing.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ def test_resolve_dependencies_missing_file(tmp_path):
125125
assert constraints == []
126126

127127

128-
@pytest.mark.skip(reason="Unrelated test from other branch - needs separate fix")
129128
def test_resolve_dependencies_simple_file(tmp_path):
130129
"""Test resolve_dependencies with a simple requirements file."""
131130
from mxdev.processing import resolve_dependencies
@@ -143,8 +142,8 @@ def test_resolve_dependencies_simple_file(tmp_path):
143142
ignore_keys=[],
144143
variety="r",
145144
)
146-
assert "requests>=2.28.0" in requirements
147-
assert "urllib3==1.26.9" in requirements
145+
assert any("requests>=2.28.0" in line for line in requirements)
146+
assert any("urllib3==1.26.9" in line for line in requirements)
148147
finally:
149148
os.chdir(old_cwd)
150149

@@ -512,13 +511,21 @@ def test_write_output_with_overrides(tmp_path):
512511
os.chdir(old_cwd)
513512

514513

515-
@pytest.mark.skip(reason="Unrelated test from other branch - needs separate fix")
516514
def test_write_output_with_ignores(tmp_path):
517515
"""Test write() with ignores."""
518516
from mxdev.config import Configuration
517+
from mxdev.processing import read
519518
from mxdev.processing import write
520519
from mxdev.state import State
521520

521+
# Create requirements.txt with packages
522+
req_in = tmp_path / "requirements.txt"
523+
req_in.write_text("requests\nmy.mainpackage==1.0.0\n-c constraints.txt\n")
524+
525+
# Create constraints.txt with packages
526+
const_in = tmp_path / "constraints.txt"
527+
const_in.write_text("urllib3==1.26.9\nmy.mainpackage==1.0.0\n")
528+
522529
config_file = tmp_path / "mx.ini"
523530
config_file.write_text(
524531
"""[settings]
@@ -532,13 +539,12 @@ def test_write_output_with_ignores(tmp_path):
532539

533540
config = Configuration(str(config_file))
534541
state = State(configuration=config)
535-
state.requirements = ["requests\n", "my.mainpackage==1.0.0\n"]
536-
state.constraints = ["urllib3==1.26.9\n", "my.mainpackage==1.0.0\n"]
537542

538543
old_cwd = os.getcwd()
539544
os.chdir(tmp_path)
540545

541546
try:
547+
read(state)
542548
write(state)
543549

544550
req_file = tmp_path / "requirements-out.txt"
@@ -591,7 +597,6 @@ def test_write_output_with_main_package(tmp_path):
591597
os.chdir(old_cwd)
592598

593599

594-
@pytest.mark.skip(reason="Unrelated test from other branch - needs separate fix")
595600
def test_write_relative_constraints_path_different_dirs(tmp_path):
596601
"""Test write() generates correct relative path for constraints file.
597602
@@ -619,9 +624,13 @@ def test_write_relative_constraints_path_different_dirs(tmp_path):
619624
"""
620625
)
621626

622-
# Create empty requirements.txt
627+
# Create requirements.txt with a constraint reference
623628
req_in = tmp_path / "requirements.txt"
624-
req_in.write_text("")
629+
req_in.write_text("requests\n-c base-constraints.txt\n")
630+
631+
# Create base constraints file with some content
632+
const_in = tmp_path / "base-constraints.txt"
633+
const_in.write_text("urllib3==1.26.9\n")
625634

626635
config = Configuration(str(config_file))
627636
state = State(configuration=config)
@@ -726,8 +735,6 @@ def test_write_dev_sources_missing_directories_raises_error(tmp_path, caplog):
726735
from mxdev.processing import write_dev_sources
727736
from mxdev.state import State
728737

729-
import pytest
730-
731738
# Create config WITHOUT offline mode (non-offline mode)
732739
config_file = tmp_path / "mx.ini"
733740
config_file.write_text(

0 commit comments

Comments
 (0)