1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
From: Arnaud Rebillout <arnaudr@debian.org>
Date: Thu, 13 Nov 2025 23:07:04 +0700
Subject: remove six from fs/test.py
Fix packages that build depend on python3-fs and import fs.test, eg.
this is what pyfatfs does:
```
from fs.test import FSTestCases
```
---
fs/test.py | 57 ++++++++++++++++++++++++++-------------------------------
1 file changed, 26 insertions(+), 31 deletions(-)
diff --git a/fs/test.py b/fs/test.py
index 52beada..6c01194 100644
--- a/fs/test.py
+++ b/fs/test.py
@@ -11,12 +11,10 @@ import io
import itertools
import json
import os
-import six
import time
import unittest
import warnings
from datetime import datetime
-from six import text_type
import fs.copy
import fs.move
@@ -24,10 +22,7 @@ from fs import ResourceType, Seek, errors, glob, walk
from fs.opener import open_fs
from fs.subfs import ClosingSubFS, SubFS
-if six.PY2:
- import collections as collections_abc
-else:
- import collections.abc as collections_abc
+import collections.abc as collections_abc
try:
from datetime import timezone
@@ -338,11 +333,11 @@ class FSTestCases(object):
contents (str): Text to compare.
"""
- assert isinstance(contents, text_type)
+ assert isinstance(contents, str)
with self.fs.open(path, "rt") as f:
data = f.read()
self.assertEqual(data, contents)
- self.assertIsInstance(data, text_type)
+ self.assertIsInstance(data, str)
def test_root_dir(self):
with self.assertRaises(errors.FileExpected):
@@ -369,7 +364,7 @@ class FSTestCases(object):
def test_basic(self):
# Check str and repr don't break
repr(self.fs)
- self.assertIsInstance(six.text_type(self.fs), six.text_type)
+ self.assertIsInstance(str(self.fs), str)
def test_getmeta(self):
# Get the meta dict
@@ -422,7 +417,7 @@ class FSTestCases(object):
except errors.NoSysPath:
self.assertFalse(self.fs.hassyspath("foo"))
else:
- self.assertIsInstance(syspath, text_type)
+ self.assertIsInstance(syspath, str)
self.assertIsInstance(self.fs.getospath("foo"), bytes)
self.assertTrue(self.fs.hassyspath("foo"))
# Should not throw an error
@@ -473,7 +468,7 @@ class FSTestCases(object):
# Check basic namespace
info = self.fs.getinfo("foo").raw
self.assertIn("basic", info)
- self.assertIsInstance(info["basic"]["name"], text_type)
+ self.assertIsInstance(info["basic"]["name"], str)
self.assertEqual(info["basic"]["name"], "foo")
self.assertFalse(info["basic"]["is_dir"])
@@ -577,13 +572,13 @@ class FSTestCases(object):
self.fs.writebytes("baz/egg", b"egg")
# Check list works
- six.assertCountEqual(self, self.fs.listdir("/"), ["foo", "bar", "baz"])
- six.assertCountEqual(self, self.fs.listdir("."), ["foo", "bar", "baz"])
- six.assertCountEqual(self, self.fs.listdir("./"), ["foo", "bar", "baz"])
+ self.assertCountEqual(self.fs.listdir("/"), ["foo", "bar", "baz"])
+ self.assertCountEqual(self.fs.listdir("."), ["foo", "bar", "baz"])
+ self.assertCountEqual(self.fs.listdir("./"), ["foo", "bar", "baz"])
# Check paths are unicode strings
for name in self.fs.listdir("/"):
- self.assertIsInstance(name, text_type)
+ self.assertIsInstance(name, str)
# Create a subdirectory
self.fs.makedir("dir")
@@ -596,10 +591,10 @@ class FSTestCases(object):
self.fs.writebytes("dir/barbar", b"egg")
# Check listing subdirectory
- six.assertCountEqual(self, self.fs.listdir("dir"), ["foofoo", "barbar"])
+ self.assertCountEqual(self.fs.listdir("dir"), ["foofoo", "barbar"])
# Make sure they are unicode stringd
for name in self.fs.listdir("dir"):
- self.assertIsInstance(name, text_type)
+ self.assertIsInstance(name, str)
self.fs.create("notadir")
with self.assertRaises(errors.DirectoryExpected):
@@ -845,7 +840,7 @@ class FSTestCases(object):
with self.fs.open("text", "w") as f:
repr(f)
- text_type(f)
+ str(f)
self.assertIsInstance(f, io.IOBase)
self.assertTrue(f.writable())
self.assertFalse(f.readable())
@@ -864,7 +859,7 @@ class FSTestCases(object):
with self.fs.open("text", "r") as f:
repr(f)
- text_type(f)
+ str(f)
self.assertIsInstance(f, io.IOBase)
self.assertFalse(f.writable())
self.assertTrue(f.readable())
@@ -946,7 +941,7 @@ class FSTestCases(object):
# Write a binary file
with self.fs.openbin("file.bin", "wb") as write_file:
repr(write_file)
- text_type(write_file)
+ str(write_file)
self.assertIn("b", write_file.mode)
self.assertIsInstance(write_file, io.IOBase)
self.assertTrue(write_file.writable())
@@ -958,7 +953,7 @@ class FSTestCases(object):
# Read a binary file
with self.fs.openbin("file.bin", "rb") as read_file:
repr(write_file)
- text_type(write_file)
+ str(write_file)
self.assertIn("b", read_file.mode)
self.assertIsInstance(read_file, io.IOBase)
self.assertTrue(read_file.readable())
@@ -1025,8 +1020,8 @@ class FSTestCases(object):
# Open a sub directory
with self.fs.opendir("foo") as foo_fs:
repr(foo_fs)
- text_type(foo_fs)
- six.assertCountEqual(self, foo_fs.listdir("/"), ["bar", "egg"])
+ str(foo_fs)
+ self.assertCountEqual(foo_fs.listdir("/"), ["bar", "egg"])
self.assertTrue(foo_fs.isfile("bar"))
self.assertTrue(foo_fs.isfile("egg"))
self.assertEqual(foo_fs.readbytes("bar"), b"barbar")
@@ -1048,7 +1043,7 @@ class FSTestCases(object):
# Check ClosingSubFS closes 'parent'
with self.fs.opendir("foo", factory=ClosingSubFS) as foo_fs:
- six.assertCountEqual(self, foo_fs.listdir("/"), ["bar", "egg"])
+ self.assertCountEqual(foo_fs.listdir("/"), ["bar", "egg"])
self.assertTrue(foo_fs.isfile("bar"))
self.assertTrue(foo_fs.isfile("egg"))
self.assertEqual(foo_fs.readbytes("bar"), b"barbar")
@@ -1329,7 +1324,7 @@ class FSTestCases(object):
# Describe a file
self.fs.create("foo")
description = self.fs.desc("foo")
- self.assertIsInstance(description, text_type)
+ self.assertIsInstance(description, str)
# Describe a dir
self.fs.makedir("dir")
@@ -1459,7 +1454,7 @@ class FSTestCases(object):
def test_readbytes(self):
# Test readbytes method.
- all_bytes = b"".join(six.int2byte(n) for n in range(256))
+ all_bytes = bytes(range(256))
with self.fs.open("foo", "wb") as f:
f.write(all_bytes)
self.assertEqual(self.fs.readbytes("foo"), all_bytes)
@@ -1502,7 +1497,7 @@ class FSTestCases(object):
self.assertTrue(self.fs.isempty("/foo"))
def test_writebytes(self):
- all_bytes = b"".join(six.int2byte(n) for n in range(256))
+ all_bytes = bytes(range(256))
self.fs.writebytes("foo", all_bytes)
with self.fs.open("foo", "rb") as f:
_bytes = f.read()
@@ -1517,7 +1512,7 @@ class FSTestCases(object):
with self.fs.open("foo/unicode.txt", "wt") as f:
f.write(UNICODE_TEXT)
text = self.fs.readtext("foo/unicode.txt")
- self.assertIsInstance(text, text_type)
+ self.assertIsInstance(text, str)
self.assertEqual(text, UNICODE_TEXT)
self.assert_text("foo/unicode.txt", UNICODE_TEXT)
@@ -1527,7 +1522,7 @@ class FSTestCases(object):
with self.fs.open("foo", "rt") as f:
foo = f.read()
self.assertEqual(foo, "bar")
- self.assertIsInstance(foo, text_type)
+ self.assertIsInstance(foo, str)
with self.assertRaises(TypeError):
self.fs.writetext("nottext", b"bytes")
@@ -1560,7 +1555,7 @@ class FSTestCases(object):
def test_bin_files(self):
# Check binary files.
with self.fs.openbin("foo1", "wb") as f:
- text_type(f)
+ str(f)
repr(f)
f.write(b"a")
f.write(b"b")
@@ -1603,7 +1598,7 @@ class FSTestCases(object):
# Test multiple writes
with self.fs.open("foo1", "wt") as f:
- text_type(f)
+ str(f)
repr(f)
f.write("a")
f.write("b")
|