Skip to content

Commit

Permalink
Import pickle from compat in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed May 20, 2020
1 parent d480598 commit f356dbd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/cloudpickle_file_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import unicode_literals

import os
import pickle
import shutil
import sys
import tempfile
Expand All @@ -10,6 +9,7 @@
import pytest

import cloudpickle
from cloudpickle.compat import pickle


class CloudPickleFileTests(unittest.TestCase):
Expand Down
10 changes: 7 additions & 3 deletions tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import logging
import math
from operator import itemgetter, attrgetter
import pickle
import platform
import random
import shutil
Expand Down Expand Up @@ -43,6 +42,7 @@
tornado = None

import cloudpickle
from cloudpickle.compat import pickle
from cloudpickle.cloudpickle import _is_dynamic
from cloudpickle.cloudpickle import _make_empty_cell, cell_set
from cloudpickle.cloudpickle import _extract_class_dict, _whichmodule
Expand Down Expand Up @@ -1228,8 +1228,12 @@ def f():
# some setup is required to allow pytest apimodules to be correctly
# serializable.
from cloudpickle import CloudPickler
from cloudpickle import cloudpickle_fast as cp_fast
CloudPickler.dispatch_table[type(py.builtin)] = cp_fast._module_reduce
if sys.version_info[:2] >= (3, 8):
from cloudpickle import cloudpickle_fast as cp_fast
CloudPickler.dispatch[
type(py.builtin)] = cp_fast._module_reduce
else:
CloudPickler.dispatch[type(py.builtin)] = CloudPickler.save_module

g = cloudpickle.loads(cloudpickle.dumps(f, protocol=self.protocol))

Expand Down

0 comments on commit f356dbd

Please sign in to comment.