<commit_before>import py
import os, sys
import pytest
from py._path.svnwc import InfoSvnWCCommand, XMLWCStatus, parse_wcinfotime
from py._path import svnwc as svncommon
from svntestbase import CommonSvnTests


pytestmark = pytest.mark.xfail(sys.platform.startswith('win'),
                               reason='#161 all tests in this file are failing on Windows',
                               run=False)


def test_make_repo(path1, tmpdir):
    repo = tmpdir.join("repo")
    py.process.cmdexec('svnadmin create %s' % repo)
    if sys.platform == 'win32':
        repo = '/' + str(repo).replace('\\', '/')
    repo = py.path.svnurl("file://%s" % repo)
    wc = py.path.svnwc(tmpdir.join("wc"))
    wc.checkout(repo)
    assert wc.rev == 0
    assert len(wc.listdir()) == 0
    p = wc.join("a_file")
    p.write("test file")
    p.add()
    rev = wc.commit("some test")
    assert p.info().rev == 1
    assert rev == 1
    rev = wc.commit()
    assert rev is None

def pytest_funcarg__path1(request):
    repo, repourl, wc = request.getfuncargvalue("repowc1")
    return wc

class TestWCSvnCommandPath(CommonSvnTests):
    def test_status_attributes_simple(self, path1):
        def assert_nochange(p):
            s = p.status()
            assert not s.modified
            assert not s.prop_modified
            assert not s.added
            assert not s.deleted
            assert not s.replaced

        dpath = path1.join('sampledir')
        assert_nochange(path1.join('sampledir'))
        assert_nochange(path1.join('samplefile'))

    def test_status_added(self, path1):
        nf = path1.join('newfile')
        nf.write('hello')
        nf.add()
        try:
            s = nf.status()
            assert s.added
            assert not s.modified
            assert not s.prop_modified
            assert not s.replaced
        finally:
            nf.revert()

    def test_status_change(self, path1):
        nf = path1.join('samplefile')
        try:
            nf.write(nf.read() + 'change')
            s = nf.status()
            assert not s.added
            assert s.modified
            assert not s.prop_modified
            assert not s.replaced
        finally:
            nf.revert()

    def test_status_added_ondirectory(self, path1):
        sampledir = path1.join('sampledir')
        try:
            t2 = sampledir.mkdir('t2')
            t1 = t2.join('t1')
            t1.write('test')
            t1.add()
            s = sampledir.status(rec=1)
            # Comparing just the file names, because paths are unpredictable
            # on Windows. (long vs. 8.3 paths)
            assert t1.basename in [item.basename for item in s.added]
            assert t2.basename in [item.basename for item in s.added]
        finally:
            t2.revert(rec=1)
            t2.localpath.remove(rec=1)

    def test_status_unknown(self, path1):
        t1 = path1.join('un1')
        try:
            t1.write('test')
            s = path1.status()
            # Comparing just the file names, because paths are unpredictable
            # on Windows. (long vs. 8.3 paths)
            assert t1.basename in [item.basename for item in s.unknown]
        finally:
            t1.localpath.remove()

    def test_status_unchanged(self, path1):
        r = path1
        s = path1.status(rec=1)
        # Comparing just the file names, because paths are unpredictable
        # on Windows. (long vs. 8.3 paths)
        assert r.join('samplefile').basename in [item.basename
                                                    for item in s.unchanged]
        assert r.join('sampledir').basename in [item.basename
                                                    for item in s.unchanged]
        assert r.join('sampledir/otherfile').basename in [item.basename
                                                    for item in s.unchanged]

    @pytest.mark.xfail(reason="svn-1.7 has buggy 'status --xml' output")
    def test_status_update(self, path1):
        r = path1
        try:
            r.update(rev=1)
            s = r.status(updates=1, rec=1)
            # Comparing just the file names, because paths are unpredictable
            # on Windows. (long vs. 8.3 paths)
            import pprint<commit_msg>Change mark from test_status_update to an imperative xfail<commit_after>import py
import os, sys
import pytest
from py._path.svnwc import InfoSvnWCCommand, XMLWCStatus, parse_wcinfotime
from py._path import svnwc as svncommon
from svntestbase import CommonSvnTests


pytestmark = pytest.mark.xfail(sys.platform.startswith('win'),
                               reason='#161 all tests in this file are failing on Windows',
                               run=False)


def test_make_repo(path1, tmpdir):
    repo = tmpdir.join("repo")
    py.process.cmdexec('svnadmin create %s' % repo)
    if sys.platform == 'win32':
        repo = '/' + str(repo).replace('\\', '/')
    repo = py.path.svnurl("file://%s" % repo)
    wc = py.path.svnwc(tmpdir.join("wc"))
    wc.checkout(repo)
    assert wc.rev == 0
    assert len(wc.listdir()) == 0
    p = wc.join("a_file")
    p.write("test file")
    p.add()
    rev = wc.commit("some test")
    assert p.info().rev == 1
    assert rev == 1
    rev = wc.commit()
    assert rev is None

def pytest_funcarg__path1(request):
    repo, repourl, wc = request.getfuncargvalue("repowc1")
    return wc

class TestWCSvnCommandPath(CommonSvnTests):
    def test_status_attributes_simple(self, path1):
        def assert_nochange(p):
            s = p.status()
            assert not s.modified
            assert not s.prop_modified
            assert not s.added
            assert not s.deleted
            assert not s.replaced

        dpath = path1.join('sampledir')
        assert_nochange(path1.join('sampledir'))
        assert_nochange(path1.join('samplefile'))

    def test_status_added(self, path1):
        nf = path1.join('newfile')
        nf.write('hello')
        nf.add()
        try:
            s = nf.status()
            assert s.added
            assert not s.modified
            assert not s.prop_modified
            assert not s.replaced
        finally:
            nf.revert()

    def test_status_change(self, path1):
        nf = path1.join('samplefile')
        try:
            nf.write(nf.read() + 'change')
            s = nf.status()
            assert not s.added
            assert s.modified
            assert not s.prop_modified
            assert not s.replaced
        finally:
            nf.revert()

    def test_status_added_ondirectory(self, path1):
        sampledir = path1.join('sampledir')
        try:
            t2 = sampledir.mkdir('t2')
            t1 = t2.join('t1')
            t1.write('test')
            t1.add()
            s = sampledir.status(rec=1)
            # Comparing just the file names, because paths are unpredictable
            # on Windows. (long vs. 8.3 paths)
            assert t1.basename in [item.basename for item in s.added]
            assert t2.basename in [item.basename for item in s.added]
        finally:
            t2.revert(rec=1)
            t2.localpath.remove(rec=1)

    def test_status_unknown(self, path1):
        t1 = path1.join('un1')
        try:
            t1.write('test')
            s = path1.status()
            # Comparing just the file names, because paths are unpredictable
            # on Windows. (long vs. 8.3 paths)
            assert t1.basename in [item.basename for item in s.unknown]
        finally:
            t1.localpath.remove()

    def test_status_unchanged(self, path1):
        r = path1
        s = path1.status(rec=1)
        # Comparing just the file names, because paths are unpredictable
        # on Windows. (long vs. 8.3 paths)
        assert r.join('samplefile').basename in [item.basename
                                                    for item in s.unchanged]
        assert r.join('sampledir').basename in [item.basename
                                                    for item in s.unchanged]
        assert r.join('sampledir/otherfile').basename in [item.basename
                                                    for item in s.unchanged]

    def test_status_update(self, path1):
        # not a mark because the global "pytestmark" will end up overwriting a mark here
        pytest.xfail("svn-1.7 has buggy 'status --xml' output")
        r = path1
        try:
            r.update(rev=1)
            s = r.status(updates=1, rec=1)
            # Comparing just the file names, because paths are unpredictable
            # on Windows. (long vs. 8.3 paths)
            import pprint
{'fraction_non_alphanumeric': 0.10186796612135979, 'fraction_numerical': 0.01461886529759833, 'mean_word_length': 1.7734877734877734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3278699', 'n_tokens_mistral': 2643, 'n_tokens_neox': 2564, 'n_words': 670}