Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add new gotcha #1158

Open
Open
@acampove

Description

Hi,

While running tests on my code I was doing something like:

class Data:
 mylist = [1,2,3,4]
def test_function():
 local_list = Data.mylist
 local_list+=new_list
 # Do stuff with 

and there are multiple tests using mylist. This is going to modify the list instead of creating a new one, an unexpected behavior of +=. This will let one test talk to the tests happening later. The safer approach is:

class Data:
 mylist = [1,2,3,4]
def test_function():
 local_list =new_list + Data.mylist
 # Do stuff with 

here + will copy the list. Could you please add this case?

Cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /