Skip to content

Commit

Permalink
xfail properly, all tests would be working now
Browse files Browse the repository at this point in the history
  • Loading branch information
ModischFabrications committed Apr 14, 2024
1 parent f759840 commit 6193b84
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
8 changes: 4 additions & 4 deletions tests/solver/data/test_Job.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,25 @@ def test_combinations():
)
assert job.n_combinations() == 72

# TODO test combined
# TODO test combined once grouping works


@pytest.mark.skip(reason="bug #73")
@pytest.mark.xfail(reason="bug #73")
def test_group_required():
job = Job(stocks=(INS(length=1000),), cut_width=10, required=(
QNS(length=88, quantity=2), QNS(length=88, quantity=1), QNS(length=88, quantity=1))
)
assert job.n_combinations_required() == 1


@pytest.mark.skip(reason="bug #73")
@pytest.mark.xfail(reason="bug #73")
def test_group_stocks():
job = Job(stocks=(INS(length=1000, quantity=2), INS(length=1000, quantity=2)), cut_width=10,
required=(QNS(length=100, quantity=2),))
assert job.n_combinations_stocks() == 1


@pytest.mark.skip(reason="bug #73")
@pytest.mark.xfail(reason="bug #73")
def test_group_stocks_infinite():
job = Job(stocks=(INS(length=1000, quantity=2), INS(length=1000)), cut_width=10,
required=(QNS(length=100, quantity=2),))
Expand Down
14 changes: 13 additions & 1 deletion tests/solver/test_large.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,25 @@ def test_m_multi(solver):

solved = solver(testjob_m)

assert solved == (
trimmings = sum(lt.trimming for lt in solved)

perfect_trimmings = 520
perfect_result = (
ResultEntry(stock=NS(length=500), cuts=(NS(length=500),), trimming=0),
ResultEntry(stock=NS(length=500), cuts=(NS(length=300),), trimming=190),
ResultEntry(stock=NS(length=900), cuts=(NS(length=500), NS(length=300)), trimming=80),
ResultEntry(stock=NS(length=900), cuts=(NS(length=500), NS(length=300)), trimming=80),
ResultEntry(stock=NS(length=900), cuts=(NS(length=500), NS(length=100), NS(length=100)), trimming=170))

if solver == _solve_bruteforce:
assert trimmings == perfect_trimmings
assert solved == perfect_result
else:
if solved != perfect_result:
pytest.xfail("heuristic has worse result")
if trimmings != perfect_trimmings:
pytest.xfail(f"heuristics has worse trimmings: {trimmings} != {perfect_trimmings}")


@pytest.mark.parametrize("solver", [_solve_FFD, _solve_gapfill])
def test_l(solver):
Expand Down
2 changes: 1 addition & 1 deletion tests/solver/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_solver_single(solver):
)


# @pytest.mark.skip(reason="bug #52")
# @pytest.mark.xfail(reason="bug #52")
@pytest.mark.parametrize("solver", [_solve_bruteforce, _solve_FFD, _solve_gapfill])
def test_solver_multi(solver):
job = Job(stocks=(INS(length=1100), INS(length=500, quantity=2)), cut_width=10,
Expand Down
6 changes: 3 additions & 3 deletions tests/solver/test_special.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)


# @pytest.mark.skip(reason="bug #63")
# @pytest.mark.xfail(reason="bug #63")
@pytest.mark.parametrize("solver", [_solve_bruteforce, _solve_FFD, _solve_gapfill])
def test_cuts(solver):
testjob_cuts = Job(stocks=(INS(length=1010),), cut_width=10, required=(QNS(length=500, quantity=4),))
Expand All @@ -20,7 +20,7 @@ def test_cuts(solver):
)


# @pytest.mark.skip(reason="bug #59")
# @pytest.mark.xfail(reason="bug #59")
@pytest.mark.parametrize("solver", [_solve_bruteforce, _solve_FFD, _solve_gapfill])
def test_zero_width_cuts(solver):
testjob_zero_cuts = Job(stocks=(INS(length=1000),), cut_width=0, required=(QNS(length=500, quantity=4),))
Expand All @@ -47,7 +47,7 @@ def test_smaller_cuts(solver):
ResultEntry(stock=NS(length=100), cuts=(NS(length=95),), trimming=0))


# @pytest.mark.skip(reason="bug #64")
# @pytest.mark.xfail(reason="bug #64")
@pytest.mark.parametrize("solver", [_solve_bruteforce, _solve_FFD, _solve_gapfill])
def test_no_cuts(solver):
testjob_equal = Job(stocks=(INS(length=1000),), cut_width=10, required=(QNS(length=1000, quantity=4),))
Expand Down

0 comments on commit 6193b84

Please sign in to comment.