Skip to content

Commit

Permalink
TST: Fix tests failing on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kernc committed Feb 18, 2025
1 parent 1dd6309 commit d59e641
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backtesting/backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1508,12 +1508,15 @@ def _batch(seq):
with mp.Pool() as pool, \
SharedMemoryManager() as smm:

shm_refs = [] # https://stackoverflow.com/questions/74193377/filenotfounderror-when-passing-a-shared-memory-to-a-new-process#comment130999060_74194875 # noqa: E501

def arr2shm(vals):
nonlocal smm
shm = smm.SharedMemory(size=vals.nbytes)
buf = np.ndarray(vals.shape, dtype=vals.dtype, buffer=shm.buf)
buf[:] = vals[:] # Copy into shared memory
assert vals.ndim == 1, (vals.ndim, vals.shape, vals)
shm_refs.append(shm)
return shm.name, vals.shape, vals.dtype

data_shm = tuple((
Expand Down
1 change: 1 addition & 0 deletions backtesting/test/_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ def test_indicators_picklable(self):
class TestDocs(TestCase):
DOCS_DIR = os.path.join(os.path.dirname(__file__), '..', '..', 'doc')

@unittest.skipIf('win' in sys.platform, "Locks up with `ModuleNotFoundError: No module named '<run_path>'`")
@unittest.skipUnless(os.path.isdir(DOCS_DIR), "docs dir doesn't exist")
def test_examples(self):
examples = glob(os.path.join(self.DOCS_DIR, 'examples', '*.py'))
Expand Down

0 comments on commit d59e641

Please sign in to comment.