[Python-modules-commits] [python-atomicwrites] 01/05: Import python-atomicwrites_1.1.5.orig.tar.gz

Filip Pytloun fpytloun-guest at moszumanska.debian.org
Mon Aug 22 17:14:19 UTC 2016


This is an automated email from the git hooks/post-receive script.

fpytloun-guest pushed a commit to branch master
in repository python-atomicwrites.

commit ecfe7186a2095f3eaed17d028d43c1340e1e823c
Author: Filip Pytloun <filip at pytloun.cz>
Date:   Mon Aug 22 19:12:10 2016 +0200

    Import python-atomicwrites_1.1.5.orig.tar.gz
---
 .travis.yml                |  9 +++++----
 CONTRIBUTING.rst           | 11 +++++++++++
 atomicwrites/__init__.py   | 10 +++++-----
 tests/test_atomicwrites.py | 22 ++++++++++++++++++++++
 tox.ini                    | 16 ++++++----------
 5 files changed, 49 insertions(+), 19 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 2f285ae..e977901 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,6 @@
 sudo: false
 os: linux
 language: python
-env:
-    - TOXENV_SUFFIX=test
-    - TOXENV_SUFFIX=stylecheck
 
 matrix:
     include:
@@ -31,4 +28,8 @@ install:
     - pip install tox
 
 script:
-    - tox -e $(echo py$TRAVIS_PYTHON_VERSION | tr -d . | sed -e 's/pypypy/pypy/')-$TOXENV_SUFFIX
+    - export TOX_PY="$(echo py$TRAVIS_PYTHON_VERSION | tr -d . | sed -e 's/pypypy/pypy/')"
+    - tox -e $TOX_PY-test
+    - if [ "$TRAVIS_PYTHON_VERSION" = "2.7" ] || [ "$TRAVIS_PYTHON_VERSION" = ".3.5" ]; then
+          tox -e $TOX_PY-stylecheck;
+      fi
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
new file mode 100644
index 0000000..86d3e4a
--- /dev/null
+++ b/CONTRIBUTING.rst
@@ -0,0 +1,11 @@
+Thanks for contributing to python-atomicwrites! This document is a
+work-in-progress. Below are a few notes that are useful for writing patches.
+
+Running the tests
+=================
+
+::
+
+    pip install tox
+    tox -e py-test
+    tox -e py-stylecheck
diff --git a/atomicwrites/__init__.py b/atomicwrites/__init__.py
index 125740f..a182c07 100644
--- a/atomicwrites/__init__.py
+++ b/atomicwrites/__init__.py
@@ -8,7 +8,7 @@ try:
 except ImportError:
     fcntl = None
 
-__version__ = '1.1.0'
+__version__ = '1.1.5'
 
 
 PY2 = sys.version_info[0] == 2
@@ -43,14 +43,14 @@ if sys.platform != 'win32':
 
     def _replace_atomic(src, dst):
         os.rename(src, dst)
-        _sync_directory(os.path.dirname(dst))
+        _sync_directory(os.path.normpath(os.path.dirname(dst)))
 
     def _move_atomic(src, dst):
         os.link(src, dst)
         os.unlink(src)
 
-        src_dir = os.path.dirname(src)
-        dst_dir = os.path.dirname(dst)
+        src_dir = os.path.normpath(os.path.dirname(src))
+        dst_dir = os.path.normpath(os.path.dirname(dst))
         _sync_directory(dst_dir)
         if src_dir != dst_dir:
             _sync_directory(src_dir)
@@ -161,7 +161,7 @@ class AtomicWriter(object):
     def get_fileobject(self, dir=None, **kwargs):
         '''Return the temporary file to use.'''
         if dir is None:
-            dir = os.path.dirname(self._path)
+            dir = os.path.normpath(os.path.dirname(self._path))
         return tempfile.NamedTemporaryFile(mode=self._mode, dir=dir,
                                            delete=False, **kwargs)
 
diff --git a/tests/test_atomicwrites.py b/tests/test_atomicwrites.py
index 3fcddd2..9577199 100644
--- a/tests/test_atomicwrites.py
+++ b/tests/test_atomicwrites.py
@@ -1,4 +1,5 @@
 import errno
+import os
 
 from atomicwrites import atomic_write
 
@@ -65,3 +66,24 @@ def test_open_reraise(tmpdir):
             f.name = "asdf"
             # Now trigger our own exception.
             assert False, "Intentional failure for testing purposes"
+
+
+def test_atomic_write_in_pwd(tmpdir):
+    orig_curdir = os.getcwd()
+    try:
+        os.chdir(str(tmpdir))
+        fname = 'ha'
+        for i in range(2):
+            with atomic_write(str(fname), overwrite=True) as f:
+                f.write('hoho')
+
+        with pytest.raises(OSError) as excinfo:
+            with atomic_write(str(fname), overwrite=False) as f:
+                f.write('haha')
+
+        assert excinfo.value.errno == errno.EEXIST
+
+        assert open(fname).read() == 'hoho'
+        assert len(tmpdir.listdir()) == 1
+    finally:
+        os.chdir(orig_curdir)
diff --git a/tox.ini b/tox.ini
index db61843..dfadf03 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,15 +1,11 @@
 [tox]
 envlist = py{26,27,py,33,34,35}-{test,stylecheck}
 
-[testenv:test]
+[testenv]
 deps =
-    pytest
+    test: pytest
+    stylecheck: flake8
+    stylecheck: flake8-import-order
 commands =
-    py.test []
-
-[testenv:stylecheck]
-deps =
-    flake8
-    flake8-import-order
-commands =
-    flake8 []
+    test: py.test []
+    stylecheck: flake8 []

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-atomicwrites.git



More information about the Python-modules-commits mailing list