Merge ~adam-collard/maas:seed-info-in-one into maas:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: 49a5f324d65cbd33c32a446ea58553dbe82fc811
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas:seed-info-in-one
Merge into: maas:master
Diff against target: 28 lines (+7/-4)
1 file modified
src/maastesting/testcase.py (+7/-4)
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
Review via email: mp+405560@code.launchpad.net

Commit message

Report the seed info in an easier to copy format

Description of the change

Before:
```
Python hash seed: {{{3757171038}}}
Random seed: {{{6b4ba8b9ef6d17b3}}}
```

After:
```

Seeds: {{{MAAS_RAND_SEED=6b4ba8b9ef6d17b3 PYTHONHASHSEED=3757171038}}}
```

The latter is copy-pastable for re-running the test

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

nice!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maastesting/testcase.py b/src/maastesting/testcase.py
index 9fc82f1..a51cb5e 100644
--- a/src/maastesting/testcase.py
+++ b/src/maastesting/testcase.py
@@ -128,16 +128,19 @@ class MAASTestCase(
128 if "MAAS_DATA" in os.environ:128 if "MAAS_DATA" in os.environ:
129 self.useFixture(MAASDataFixture())129 self.useFixture(MAASDataFixture())
130130
131 rand_seed = os.environ.get("MAAS_RAND_SEED", None)131 rand_seed = os.environ.get("MAAS_RAND_SEED")
132 random.seed(rand_seed)132 random.seed(rand_seed)
133 seed_info = []
133 if rand_seed is not None:134 if rand_seed is not None:
134 self.addDetail("Random seed", text_content(rand_seed))135 seed_info.append(f"MAAS_RAND_SEED={rand_seed}")
135136
136 if "PYTHONHASHSEED" in os.environ:137 if "PYTHONHASHSEED" in os.environ:
137 self.addDetail(138 seed_info.append(
138 "Python hash seed", text_content(os.environ["PYTHONHASHSEED"])139 "PYTHONHASHSEED={}".format(os.environ["PYTHONHASHSEED"])
139 )140 )
140141
142 if seed_info:
143 self.addDetail("Seeds", text_content(" ".join(seed_info)))
141 # Capture Twisted logs and add them as a test detail.144 # Capture Twisted logs and add them as a test detail.
142 twistedLog = self.useFixture(TwistedLoggerFixture())145 twistedLog = self.useFixture(TwistedLoggerFixture())
143 self.addDetail("Twisted logs", twistedLog.getContent())146 self.addDetail("Twisted logs", twistedLog.getContent())

Subscribers

People subscribed via source and target branches