You are using the wrong function. Here are the docs:
dumps(obj, protocol=None, *, fix_imports=True)
Return the marinated representation of an object as an object bytes.
dumpsconverts the passed object to bytesand returns it. An error occurs when you pass a file argument to what it .dumpexpects to be an etching protocol, which must be an integer.
You want to use pickle.dumpthat is actually uploaded to a file:
dump(obj, file, protocol=None, *, fix_imports=True)
obj file.
with open('test', 'wb') as file:
pickle.dump(test, file)