Ticket #6265 enhancement closed fixed

Opened 4 months ago

Last modified 3 months ago

SafeRepr.test_brokenReprIncludesID

Reported by: tom.prince Owned by: tom.prince
Priority: normal Milestone:
Component: core Keywords: easy
Cc: thijs Branch: branches/improve-SafeRepr.test_brokenReprIncludesID-6265
Author: tomprince Launchpad Bug:

Description

In #5544, exarkun suggests that assertion made by twisted.python.test.test_reflectpy3.SafeRepr.test_brokenReprIncludesID is too weak.

It should probably assert about what exactly the string should look like, rather than just that it has a particular substring.

Attachments

6265.patch Download (0.5 KB) - added by hash14 4 months ago.
Stricter testing of id() in test_brokenReprIncludesID

Change History

1

Changed 4 months ago by thijs

  • cc thijs added
  • keywords easy added

Changed 4 months ago by hash14

Stricter testing of id() in test_brokenReprIncludesID

2

Changed 4 months ago by hash14

Note that the patch assumes that className and formatter.name in twisted.python._reflectpy3._safeFormat will always be BrokenType and repr respectively. Not sure if this is a safe assumption, please advise...

3

Changed 4 months ago by hash14

  • keywords review added

4

Changed 3 months ago by tom.prince

  • owner set to tom.prince
  • keywords review removed

Thanks for your contribution.

When calling safe_repr, the formatter is going to be repr and BrokenType is a name coming from the test-suite, so in this test, it will always be that.

  1. There should be spaces around operators like %.
  2. A comment on why only the first line of the repr is looked at would be helpful for people looking at the code in the future.

I'll fix these two things up, and then merge.

5

Changed 3 months ago by tomprince

  • branch set to branches/improve-SafeRepr.test_brokenReprIncludesID-6265
  • branch_author set to tomprince

(In [37111]) Branching to improve-SafeRepr.test_brokenReprIncludesID-6265.

6

Changed 3 months ago by tomprince

(In [37112]) Apply patch from hash14.

Refs #6265.

7

Changed 3 months ago by tom.prince

Also, there was a twistedchecker error: String formatting operations should always use a tuple for non-mapping values

8

Changed 3 months ago by tomprince

  • status changed from new to closed
  • resolution set to fixed

(In [37116]) Merge improve-SafeRepr.test_brokenReprIncludesID-6265: Assert about the actual format of the repr.

Author: hash14 Reviewers: tom.prince Fixes: #6265

Note: See TracTickets for help on using tickets.