Skip to content

Commit

Permalink
Merge pull request #19 from brainsik/windows
Browse files Browse the repository at this point in the history
Support Windows
  • Loading branch information
brainsik authored Aug 13, 2024
2 parents 96bb8bc + 1d0b17d commit 41fb8b2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ jobs:

test:
needs: [lint, build]
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.10"]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -102,11 +103,13 @@ jobs:
pip install --disable-pip-version-check pytest
- name: Install json-store package
shell: bash # so this works on both Linux and Windows
run: |
pip install --disable-pip-version-check dist/json_store-*.whl
- name: Test with pytest
run: pytest

- name: Test shelve2json
if: ${{ matrix.os != 'windows-latest' }} # shelve.open has an internal traceback on Windows
run: sh tests/test_shelve2json.sh
2 changes: 1 addition & 1 deletion json_store/json_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def sync(self, json_kw=None, force=False):
json.dump(self._data, fp, **json_kw)
if self.mode != MODE_600: # _mktemp uses 0600 by default
os.chmod(fp.name, self.mode)
os.rename(fp.name, self.path)
os.replace(fp.name, self.path)

self._synced_json_kw = json_kw
self._needs_sync = False
Expand Down
8 changes: 5 additions & 3 deletions tests/test_json_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import absolute_import, unicode_literals

import os
import platform
import shutil
import stat
from tempfile import NamedTemporaryFile
Expand Down Expand Up @@ -154,10 +155,11 @@ def test_set_mode():
store = get_new_store(mode=int("640", 8))
try:
st_mode = os.stat(store.path).st_mode
is_windows = platform.system() == "Windows"
assert st_mode & stat.S_IRUSR
assert st_mode & stat.S_IWUSR
assert st_mode & stat.S_IRGRP
assert not st_mode & stat.S_IWGRP
assert not st_mode & stat.S_IROTH
assert st_mode & stat.S_IRGRP or is_windows
assert not st_mode & stat.S_IWGRP or is_windows
assert not st_mode & stat.S_IROTH or is_windows
finally:
os.remove(store.path)

0 comments on commit 41fb8b2

Please sign in to comment.