MCPcopy
hub / github.com/redis/redis-py / teardown

Method teardown

tests/test_commands.py:128–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126 username = "redis-py-auth"
127
128 def teardown():
129 try:
130 # this is needed because after an AuthenticationError the connection
131 # is closed, and if we send an AUTH command a new connection is
132 # created, but in this case we'd get an "Authentication required"
133 # error when switching to the db 9 because we're not authenticated yet
134 # setting the password on the connection itself triggers the
135 # authentication in the connection's `on_connect` method
136 r.connection.password = temp_pass
137 except AttributeError:
138 # connection field is not set in Redis Cluster, but that's ok
139 # because the problem discussed above does not apply to Redis Cluster
140 pass
141 r.auth(temp_pass)
142 r.config_set("requirepass", "")
143 r.acl_deluser(username)
144
145 request.addfinalizer(teardown)
146

Callers

nothing calls this directly

Calls 3

authMethod · 0.80
acl_deluserMethod · 0.80
config_setMethod · 0.45

Tested by

no test coverage detected