Skip to content

Commit

Permalink
Nicer test logs
Browse files Browse the repository at this point in the history
  • Loading branch information
stanmart committed Apr 19, 2024
1 parent dcd8a10 commit 6067630
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
source venv/bin/activate
pip install -r requirements.txt
- run: echo "$PWD/venv/bin" >> $GITHUB_PATH
- run: timeout 5 otree devserver & otree test bargaining_test
- run: timeout 5 otree devserver & otree test bargaining_test 2> stderr.log || cat stderr.log; rm stderr.log
16 changes: 9 additions & 7 deletions live_bargaining/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,42 +154,42 @@ def test_invalid_input(method):


def call_live_method(method, **kwargs):
# Invalid input
print(f"Round {kwargs['round_number']}: ", end="")

if kwargs["round_number"] == 1:
print("Testing invalid input")
test_invalid_input(method)

# Grand coalition
if kwargs["round_number"] == 2:
print("Testing grand coalition")
create_offers(method)
method(3, {"type": "accept", "offer_id": 1})
method(1, {"type": "accept", "offer_id": 2})
method(2, {"type": "accept", "offer_id": 2})
method(3, {"type": "accept", "offer_id": 2})

# No agreement
if kwargs["round_number"] == 3:
print("Testing no agreement")
create_offers(method)
method(1, {"type": "accept", "offer_id": 2})
method(2, {"type": "accept", "offer_id": 2})
method(3, {"type": "accept", "offer_id": 1})

# Smaller coalition
if kwargs["round_number"] == 4:
print("Testing smaller coalition")
create_offers(method)
method(1, {"type": "accept", "offer_id": 3})
method(2, {"type": "accept", "offer_id": 3})
method(3, {"type": "accept", "offer_id": 1})

# Revoke acceptance
if kwargs["round_number"] == 5:
print("Testing revoking acceptance")
create_offers(method)
method(1, {"type": "accept", "offer_id": 1})
method(2, {"type": "accept", "offer_id": 1})
method(3, {"type": "accept", "offer_id": 1})
method(2, {"type": "accept", "offer_id": 0})

print("Payoffs: ")


class PlayerBot(Bot):
def play_round(self):
Expand Down Expand Up @@ -219,4 +219,6 @@ def play_round(self):
if self.round_number == 5:
expect(self.player.payoff, c(0))

print(f"Player {self.player.id_in_group} received payoff: {self.player.payoff}")

yield BargainingResults

0 comments on commit 6067630

Please sign in to comment.