()
| 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 |
nothing calls this directly
no test coverage detected