<commit_before>"""

  fs.tests.test_fs:  testcases for basic FS implementations

"""

from fs.tests import FSTestCases, ThreadingTestCases
from fs.path import *
from fs import errors

import unittest

import os
import sys
import shutil
import tempfile


from fs import osfs
class TestOSFS(unittest.TestCase,FSTestCases,ThreadingTestCases):

    def setUp(self):
        self.temp_dir = tempfile.mkdtemp(u"fstest")
        self.fs = osfs.OSFS(self.temp_dir)

    def tearDown(self):
        shutil.rmtree(self.temp_dir)
        self.fs.close()

    def check(self, p):
        return os.path.exists(os.path.join(self.temp_dir, relpath(p)))

    def test_invalid_chars(self):
        self.assertEqual(self.fs.validatepath(''), None)
        self.assertEqual(self.fs.validatepath('.foo'), None)
        self.assertEqual(self.fs.validatepath('foo'), None)
        self.assertEqual(self.fs.validatepath('foo/bar'), None)
        self.assert_(self.fs.isvalidpath('foo/bar'))

        self.assertRaises(errors.InvalidCharsInPathError, self.fs.open, 'invalid\0file', 'wb')
        self.assertFalse(self.fs.isvalidpath('invalid\0file'))
        self.assert_(self.fs.isvalidpath('validfile'))
        self.assert_(self.fs.isvalidpath('completely_valid/path/foo.bar'))


class TestSubFS(unittest.TestCase,FSTestCases,ThreadingTestCases):

    def setUp(self):
        self.temp_dir = tempfile.mkdtemp(u"fstest")
        self.parent_fs = osfs.OSFS(self.temp_dir)
        self.parent_fs.makedir("foo/bar", recursive=True)
        self.fs = self.parent_fs.opendir("foo/bar")

    def tearDown(self):
        shutil.rmtree(self.temp_dir)
        self.fs.close()

    def check(self, p):
        p = os.path.join("foo/bar", relpath(p))
        full_p = os.path.join(self.temp_dir, p)
        return os.path.exists(full_p)


from fs import memoryfs
class TestMemoryFS(unittest.TestCase,FSTestCases,ThreadingTestCases):

    def setUp(self):
        self.fs = memoryfs.MemoryFS()
<commit_msg>Change test_invalid_chars to call the base version first (eliminates duplicate code)<commit_after>"""

  fs.tests.test_fs:  testcases for basic FS implementations

"""

from fs.tests import FSTestCases, ThreadingTestCases
from fs.path import *
from fs import errors

import unittest

import os
import sys
import shutil
import tempfile


from fs import osfs
class TestOSFS(unittest.TestCase,FSTestCases,ThreadingTestCases):

    def setUp(self):
        self.temp_dir = tempfile.mkdtemp(u"fstest")
        self.fs = osfs.OSFS(self.temp_dir)

    def tearDown(self):
        shutil.rmtree(self.temp_dir)
        self.fs.close()

    def check(self, p):
        return os.path.exists(os.path.join(self.temp_dir, relpath(p)))

    def test_invalid_chars(self):
        super(TestOSFS, self).test_invalid_chars()

        self.assertRaises(errors.InvalidCharsInPathError, self.fs.open, 'invalid\0file', 'wb')
        self.assertFalse(self.fs.isvalidpath('invalid\0file'))
        self.assert_(self.fs.isvalidpath('validfile'))
        self.assert_(self.fs.isvalidpath('completely_valid/path/foo.bar'))


class TestSubFS(unittest.TestCase,FSTestCases,ThreadingTestCases):

    def setUp(self):
        self.temp_dir = tempfile.mkdtemp(u"fstest")
        self.parent_fs = osfs.OSFS(self.temp_dir)
        self.parent_fs.makedir("foo/bar", recursive=True)
        self.fs = self.parent_fs.opendir("foo/bar")

    def tearDown(self):
        shutil.rmtree(self.temp_dir)
        self.fs.close()

    def check(self, p):
        p = os.path.join("foo/bar", relpath(p))
        full_p = os.path.join(self.temp_dir, p)
        return os.path.exists(full_p)


from fs import memoryfs
class TestMemoryFS(unittest.TestCase,FSTestCases,ThreadingTestCases):

    def setUp(self):
        self.fs = memoryfs.MemoryFS()

{'fraction_non_alphanumeric': 0.12397350993377483, 'fraction_numerical': 0.0010596026490066225, 'mean_word_length': 3.458087367178276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1159117', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1278, 'n_words': 215}