Is it possible to break a long function name across multiple lines?

后端 未结 7 1121
南旧
南旧 2021-02-04 23:02

Our development team uses a PEP8 linter which requires a maximum line length of 80 characters.

When I\'m writing unit tests in python, I like to have

7条回答
  •  清酒与你
    2021-02-04 23:32

    The need for this kind of names may hint at other smells.

    class ClientConnectionTest(unittest.TestCase):
       def test_that_client_event_listener_receives_connection_refused_error_without_server(self):
           ...
    

    ClientConnectionTest sounds pretty broad (and not at all like a testable unit), and is likely a large class with plenty of tests inside that could be refocused. Like this:

    class ClientEventListenerTest(unittest.TestCase):
      def receives_connection_refused_without_server(self):
          ...
    

    "Test" is not useful in the name because it's implied.

    With all the code you've given me, my final advice is: refactor your test code, then revisit your problem (if it's still there).

提交回复
热议问题