Skip to content

Commit

Permalink
Remove outdated Python2 code
Browse files Browse the repository at this point in the history
Remove `six` package
  • Loading branch information
Rotzbua committed Oct 24, 2023
1 parent 5e9ef5d commit 1849bc4
Show file tree
Hide file tree
Showing 15 changed files with 6 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/share/miniconda/envs/test/lib/libstdc++.so.6
- name: Install testing dependencies
run: |
conda install -c conda-forge --file requirements-conda.txt --file requirements-linting-old.txt six packaging pytest coveralls coverage libstdcxx-ng
conda install -c conda-forge --file requirements-conda.txt --file requirements-linting-old.txt packaging pytest coveralls coverage libstdcxx-ng
pip install git+https://github.com/JohannesBuchner/coverage-lcov
- name: Conda info
run: |
Expand Down
1 change: 0 additions & 1 deletion examples/hashimages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function

import sys

Expand Down
1 change: 0 additions & 1 deletion find_similar_images.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function

from PIL import Image

Expand Down
1 change: 0 additions & 1 deletion imagehash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
>>>
"""

from __future__ import absolute_import, division, print_function

import sys

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

try:
from setuptools import setup
Expand Down
2 changes: 0 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from __future__ import absolute_import, division, print_function

from .utils import TestImageHash # noqa: F401 Testing the import
2 changes: 0 additions & 2 deletions tests/test_average_hash.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division, print_function

import unittest

import imagehash
Expand Down
2 changes: 0 additions & 2 deletions tests/test_colorhash.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division, print_function

import unittest

import imagehash
Expand Down
2 changes: 0 additions & 2 deletions tests/test_crop_resistant_hash.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division, print_function

import unittest
from datetime import datetime

Expand Down
2 changes: 0 additions & 2 deletions tests/test_dhash.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division, print_function

import unittest

import imagehash
Expand Down
2 changes: 0 additions & 2 deletions tests/test_hex_conversions_multihash.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import (absolute_import, division, print_function)

import unittest

import imagehash
Expand Down
2 changes: 0 additions & 2 deletions tests/test_phash.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division, print_function

import unittest

import imagehash
Expand Down
3 changes: 1 addition & 2 deletions tests/test_readme.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import six


def test_run():
Expand All @@ -12,4 +11,4 @@ def test_run():

code = ''.join(chunk)
print("running::\n" + code)
print("result:", six.exec_(code, {}, {}))
print("result:", exec(code, {}, {}))
11 changes: 4 additions & 7 deletions tests/test_whash.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from __future__ import absolute_import, division, print_function

import unittest

import six
from PIL import Image

import imagehash
Expand Down Expand Up @@ -50,14 +47,14 @@ def test_hash_size_for_small_images(self):
def test_hash_size_not_2power(self):
emsg = 'hash_size is not power of 2'
for hash_size in [3, 7, 12]:
with six.assertRaisesRegex(self, AssertionError, emsg):
with self.assertRaisesRegex(AssertionError, emsg):
imagehash.whash(self.image, hash_size=hash_size)

def test_hash_size_is_less_than_image_scale(self):
image = self._get_white_image((120, 200))
emsg = 'hash_size in a wrong range'
for hash_size in [128, 512]:
with six.assertRaisesRegex(self, AssertionError, emsg):
with self.assertRaisesRegex(AssertionError, emsg):
imagehash.whash(image, hash_size=hash_size, image_scale=64)

def test_custom_hash_size_and_scale(self):
Expand All @@ -67,13 +64,13 @@ def test_custom_hash_size_and_scale(self):

def test_hash_size_more_than_scale(self):
emsg = 'hash_size in a wrong range'
with six.assertRaisesRegex(self, AssertionError, emsg):
with self.assertRaisesRegex(AssertionError, emsg):
imagehash.whash(self.image, hash_size=32, image_scale=16)

def test_image_scale_not_2power(self):
emsg = 'image_scale is not power of 2'
for image_scale in [4, 8, 16]:
with six.assertRaisesRegex(self, AssertionError, emsg):
with self.assertRaisesRegex(AssertionError, emsg):
imagehash.whash(self.image, image_scale=image_scale + 1)


Expand Down
2 changes: 0 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import, division, print_function

import os
import os.path
import unittest
Expand Down

0 comments on commit 1849bc4

Please sign in to comment.