tests.conftest moduleΒΆ
- tests.conftest.BOX_TYPES = (<class 'mailbox.Maildir'>, <class 'mailbox.mbox'>, <class 'mailbox.MH'>, <class 'mailbox.Babyl'>, <class 'mailbox.MMDF'>, <class 'mail_deduplicate.mail_box.EML'>)ΒΆ
All box classes the
make_box/check_boxhelpers know how to build and read.Covers every format in
BoxFormat, so tests can parametrize over the whole set.
- tests.conftest.ALL_FORMATS = MarkDecorator(mark=Mark(name='parametrize', args=('box_format', (<BoxFormat.MAILDIR: (<class 'mailbox.Maildir'>, <BoxStructure.FOLDER: 1>, <class 'mail_deduplicate.mail_box.MaildirDedupMail'>)>, <BoxFormat.MBOX: (<class 'mailbox.mbox'>, <BoxStructure.FILE: 2>, <class 'mail_deduplicate.mail_box.mboxDedupMail'>)>, <BoxFormat.MH: (<class 'mailbox.MH'>, <BoxStructure.FOLDER: 1>, <class 'mail_deduplicate.mail_box.MHDedupMail'>)>, <BoxFormat.BABYL: (<class 'mailbox.Babyl'>, <BoxStructure.FILE: 2>, <class 'mail_deduplicate.mail_box.BabylDedupMail'>)>, <BoxFormat.MMDF: (<class 'mailbox.MMDF'>, <BoxStructure.FILE: 2>, <class 'mail_deduplicate.mail_box.MMDFDedupMail'>)>, <BoxFormat.EML: (<class 'mail_deduplicate.mail_box.EML'>, <BoxStructure.FOLDER: 1>, <class 'mail_deduplicate.mail_box.EMLDedupMail'>)>)), kwargs={'ids': <class 'str'>}))ΒΆ
Sweeps a test over every
BoxFormat, to check a behavior shared by all of them.
- tests.conftest.DEDUP_ARGS = ('--strategy=select-newest', '--action=delete-discarded', '--dry-run')ΒΆ
A run that exercises every step without touching the mails on disk.
- tests.conftest.cache_home(tmp_path)[source]ΒΆ
Point the cache directory of
mdedupto a folder of the test.A run that ends with a bug report saves it in the cache directory. Pointing
XDG_CACHE_HOMEandLOCALAPPDATAhere keeps every test out of the cache of the user running the suite: the tests inside therunnerfixture, the tests that call the code directly, and the subprocesses they start.The variables go through a
MonkeyPatchof its own. Themonkeypatchfixture would then outlive therunnerfixture of each test, and restore a working directory that the runner already removed.
- tests.conftest.config()[source]ΒΆ
A fully-populated
Configcarrying the CLI defaults.Lets unit tests instantiate
Deduplicateand friends without going through the Click command. Mutate the returned mapping to exercise a specific setting.- Return type:
- class tests.conftest.MailFactory(**custom_fields)[source]ΒΆ
Bases:
objectCreate fake mail messages to serve as unittest fixtures.
Help production of either random, customized or deterministic mail message.
Init the mail with custom fields.
You can bypass data normalization by passing the pre-formatted date string with
date_rfc2822custom field instead ofdate.- render()[source]ΒΆ
Returns the full, rendered content of the mail.
No blank line separates the headers from the body: the parser then ends the headers on the first body line and records a
MissingHeaderBodySeparatorDefect, so every fixture built here exercises that path. A test that needs the separator writes its bytes by hand.
- tests.conftest.make_box(tmp_path)[source]ΒΆ
A generic fixture to produce a temporary box of mails.
The mail container can be created in any format supported by Pythonβs standard library, plus the custom
emlformat, via thebox_typeparameter. Supported values are listed inBOX_TYPES.
- tests.conftest.metrics(output)[source]ΒΆ
Extracts the name and value of every metric of a runβs report tables.
- tests.conftest.mail_files(box_path)[source]ΒΆ
Every mail file of a folder-based box, in a stable order.
Dot-prefixed files are left out, as every folder-based format skips them when listing its mails: the temporary link the hardlinking action goes through is one of them.
- tests.conftest.check_box(box_path, box_type, content=None)[source]ΒΆ
Check the content of a mail box, in any of the
BOX_TYPESformats.Compares the bytes of each mail, as its box hands them out, with the bytes the expected mail was rendered from: a mail rewritten on its way into the box fails the check, where comparing parsed messages would hide the rewrite. An
mboxends every mail with a line break, so an expected mail lacking one gets it.Counts the occurrences of each mail, so a copy missing from the box or added to it fails the check, where comparing sets would silently deduplicate them.
- tests.conftest.assert_one_line_error(result, *messages)[source]ΒΆ
Check that a problem the user can fix ended the run with a one-line error.
The
stderrof the run holds each of themessages. It holds no traceback and no invitation to file a bug report, which belong to the errors that are bugs.- Return type: