class MyClass(object):and you want to test the functionality of the class, but need to change the value of myattr from the default:
myattr = 1
import mock
import modulename
with mock.patch.object(modulename.MyClass, "myattr", new=50):
# do test stuff