tests.test_bug_report moduleΒΆ

tests.test_bug_report.DOOMED_ID = '<doomed@orchard.example>'ΒΆ

Message-ID of the test mail that the patched code fails on.

tests.test_bug_report.MAIL_FACTORY_CONTENT = ('foo@bar.com', 'A duplicate mail', 'Π”Π°, ΠΎΠ½ΠΈ лСтят.')ΒΆ

Header values and body of every MailFactory mail, which no report may show.

tests.test_bug_report.PERSONAL = ('Clementine Orchard', 'clementine@orchard.example', 'quince@orchard.example', 'Picnic in Lyon', 'pear-123', 'Fig-Boundary-77', 'pommes', 'plum tart', 'harvest-plan.pdf')ΒΆ

Names, addresses and words the test mails spell out, and no fingerprint shows.

tests.test_bug_report.PREAMBLE_MAIL = b'From: Clementine Orchard <clementine@orchard.example>\r\nTo: quince@orchard.example\r\nSubject: Picnic in Lyon\r\nDate: Thu, 11 Oct 2018 09:30:00 +0800\r\nMessage-ID: <pear-123@orchard.example>\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary="Fig-Boundary-77"\r\n\r\nG\xc3\xa2teau aux pommes pr\xc3\xa9par\xc3\xa9.\r\n--Fig-Boundary-77\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: 8bit\r\n\r\nBring the plum tart.\r\n--Fig-Boundary-77\r\nContent-Type: application/pdf; name="harvest-plan.pdf"\r\nContent-Disposition: attachment; filename="harvest-plan.pdf"\r\nContent-Transfer-Encoding: base64\r\n\r\nJVBERi0xLjQgYXBwbGVzIGFuZCBwZWFycw==\r\n--Fig-Boundary-77--\r\n'ΒΆ

A multipart mail with 8-bit UTF-8 bytes in its preamble, as in https://github.com/kdeldycke/mail-deduplicate/issues/1085

tests.test_bug_report.EIGHT_BIT_MAIL = b'From: Clementine Orchard <clementine@orchard.example>\nTo: quince@orchard.example\nSubject: Picnic in Lyon, \xc3\xa0 midi\nDate: [mail_date]\nMessage-ID: <pear-123@orchard.example>\nContent-Type: text/plain; charset=us-ascii\n\nBring the plum tart, \xc3\xa0 bient\xc3\xb4t.\n'ΒΆ

A mail with 8-bit header values, a body its charset cannot decode and a Date that is no date, as in https://github.com/kdeldycke/mail-deduplicate/issues/954

tests.test_bug_report.report_url(title)[source]ΒΆ

The URL of the bug report form that a report links to, with title filled in.

Return type:

str

tests.test_bug_report.report_block(output)[source]ΒΆ

The lines between the two markers of the bug report in a run’s output.

Return type:

str

tests.test_bug_report.saved_report(output)[source]ΒΆ

The content of the file that the last line of a run’s output names.

The file sits in the reports folder of the cache, and holds the report as it is printed, from its headline to its end marker, without its own path.

Return type:

str

tests.test_bug_report.fail_on_doomed(monkeypatch, method, error)[source]ΒΆ

Make a method of the mails raise error on the mail carrying DOOMED_ID.

Return type:

None

tests.test_bug_report.worker_state(monkeypatch)[source]ΒΆ

Isolate the state a worker function sets up when called in the test process.

tests.test_bug_report.test_fingerprint_shows_no_content(raw)[source]ΒΆ

A fingerprint shows no name, address, subject, body or file name.

tests.test_bug_report.test_fingerprint_shows_mime_structure()[source]ΒΆ

The structure of a multipart mail shows, down to its preamble.

The preamble is what https://github.com/kdeldycke/mail-deduplicate/issues/1085 tripped on.

tests.test_bug_report.test_fingerprint_shows_8bit_values()[source]ΒΆ

8-bit header values and an undecodable body show by their kind of bytes.

A Date shows as it is, even when it is no date.

tests.test_bug_report.test_fingerprint_describes_broken_mails(raw, expected)[source]ΒΆ

A broken mail still gets a fingerprint, which shows what is wrong with it.

tests.test_bug_report.test_fingerprint_shows_header_values(raw, expected)[source]ΒΆ

Header values show by their shape, and a Content-Type by its structure.

A Date shows as it is, but for its comments, up to a capped length.

tests.test_bug_report.test_fingerprint_masks_comments(name)[source]ΒΆ

Each header shown as it is shows its comments by their shape alone.

tests.test_bug_report.test_fingerprint_failure_is_reported(monkeypatch)[source]ΒΆ

A mail the fingerprint cannot describe gets a line saying so.

The bug report still renders.

tests.test_bug_report.test_bytes_recovered_from_surrogates()[source]ΒΆ

The surrogate parsing leaves for a non-ASCII byte turns back into that byte.

A surrogate from no byte shows as the invalid UTF-8 it is.

tests.test_bug_report.test_fingerprint_length_is_capped()[source]ΒΆ

A mail with hundreds of headers does not flood the report.

tests.test_bug_report.test_issues_url_matches_package_metadata()[source]ΒΆ

The URL the report gives is the Issues URL of the package.

tests.test_bug_report.test_traceback_holds_no_path()[source]ΒΆ

The traceback of a report names modules and lines, and no file.

tests.test_bug_report.test_traceback_starts_in_the_blamed_block()[source]ΒΆ

The frame of blame() that catches the error stays out of the traceback.

The traceback names a method with its class.

tests.test_bug_report.dive(depth)[source]ΒΆ

Raise an error from depth calls further down.

Return type:

None

tests.test_bug_report.test_traceback_keeps_the_innermost_frames()[source]ΒΆ

A deep traceback keeps the frames closest to the error, and counts the rest.

tests.test_bug_report.test_failure_describes_its_error(error, expected)[source]ΒΆ

A failure names the class of its error, then its message, on one capped line.

The module of the class shows, outside the builtins.

tests.test_bug_report.test_unknown_box_format_shows_its_class()[source]ΒΆ

A mail from no known box format shows in the report by its class name.

tests.test_bug_report.test_failure_log_keeps_a_few_samples()[source]ΒΆ

Every failure is counted, but only the first ones of a kind are kept.

The kept ones carry their traceback.

tests.test_bug_report.test_title_names_the_innermost_function_of_mdedup(monkeypatch, config, owner, name, function)[source]ΒΆ

The title names the innermost function of mdedup the error went through.

The frames of Python, of a library and of a generator expression do not count, as in the traceback of https://github.com/kdeldycke/mail-deduplicate/issues/1117

tests.test_bug_report.KINDS_OF_ERROR = (<class 'ValueError'>, <class 'KeyError'>, <class 'TypeError'>, <class 'IndexError'>, <class 'ZeroDivisionError'>, <class 'OverflowError'>, <class 'AttributeError'>)ΒΆ

Error classes raised from one line, each of which makes a kind of failure.

tests.test_bug_report.test_failure_log_details_a_few_kinds(kinds, summary)[source]ΒΆ

The report details the most frequent kinds of failure and counts the rest.

tests.test_bug_report.test_report_version_matches_version_option()[source]ΒΆ

The report gives the version mdedup --version prints.

That version names the commit of a development build.

A real run, as --version resolves the CLI from the stack, which a CliRunner invoking the command from another module misleads.

A report links to the bug report form, with its title filled in.

Its block names mdedup and its version, then gives the formats of the sources before the details.

tests.test_bug_report.test_hashing_error_sets_the_mail_aside(invoke, make_box, monkeypatch, box_format)[source]ΒΆ

A mail that fails hashing is set aside and left untouched.

The others are deduplicated, and the run ends with a bug report.

tests.test_bug_report.test_mail_failing_to_read_is_rejected_or_set_aside(invoke, make_box, monkeypatch, failing, error, outcome, exit_code, counted)[source]ΒΆ

A mail that cannot be read is rejected on a system error, or else set aside.

Either way, it is left untouched while the others are deduplicated.

tests.test_bug_report.test_hash_only_reports_failures(invoke, make_box, monkeypatch)[source]ΒΆ

--hash-only prints the hashes it computed, then reports the failed mails.

tests.test_bug_report.test_debug_log_holds_traceback_of_samples(invoke, make_box, monkeypatch)[source]ΒΆ

At the debug level, the log holds the full traceback of each failure.

These are the failures the report details.

tests.test_bug_report.test_report_masks_paths_and_regexps(invoke, make_box, monkeypatch)[source]ΒΆ

The options of a report show the values that drive the run.

Paths and regular expressions, which can name folders and people, are replaced.

tests.test_bug_report.test_selection_error_skips_the_set(invoke, make_box, monkeypatch, box_type)[source]ΒΆ

A set that fails selection is skipped, and none of its mails is acted upon.

tests.test_bug_report.test_action_error_names_its_mail(invoke, make_box, monkeypatch, tmp_path, action, patched, step, function)[source]ΒΆ

An unexpected error in an action stops the run with a bug report.

The report names and describes the mail the action was working on.

tests.test_bug_report.test_error_before_the_steps_ends_with_a_report(invoke, make_box, monkeypatch)[source]ΒΆ

An unexpected error raised before the steps also ends with a bug report.

No step is running, so the report names the function of the command, and neither a step nor a source format.

tests.test_bug_report.test_action_system_error_is_one_line(invoke, make_box, monkeypatch)[source]ΒΆ

An OSError in an action is a system problem, which the user can fix.

The run ends with a one-line error naming the mail, and no bug report.

tests.test_bug_report.test_hashing_worker_rejects_or_sets_aside_its_mail(config, make_box, monkeypatch, worker_state, failing, error, rejection)[source]ΒΆ

A worker process answers with strings, so one failing mail spares the pool.

It rejects a mail it cannot read or hash for a reason the user can fix, as this process does, and sends any other error back as a failure.

tests.test_bug_report.test_hashing_worker_leaves_a_mail_with_too_few_headers_unhashed(config, make_box, monkeypatch, worker_state)[source]ΒΆ

A worker sends back why a mail has no hash, and the parent keeps the mail.

The verdict travels in a field of its own, apart from a rejection, as the parent keeps this mail in the selection where it drops a rejected one.

tests.test_bug_report.test_selection_worker_skips_its_set(config, make_box, monkeypatch, worker_state, failing)[source]ΒΆ

A worker skips a set it cannot settle, and accounts for all of its mails.

The parent merges that verdict back, and keeps the failure of a bug for the report.

tests.test_bug_report.test_statistics_self_check_reports_a_bug(config, caplog, operator, found, retained)[source]ΒΆ

Statistics that do not add up, or that the check cannot compare, end the run.

The run exits with code 115 and a bug report.

tests.test_bug_report.test_saved_reports_never_overwrite()[source]ΒΆ

Each report gets a file of its own, even two saved within the same second.

tests.test_bug_report.test_report_stands_alone_when_it_cannot_be_saved(caplog)[source]ΒΆ

A report the cache directory cannot hold is printed all the same.