Changeset 1657:30dd49b6f22c


Ignore:
Timestamp:
Jul 26, 2016, 9:12:39 PM (4 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Adapt `test_tool.py` for pytest

ticket: 98
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/test_tool.py

    r1564 r1657  
    1 # Copyright (C) 2013, Stefan Schwarzer
     1# Copyright (C) 2013-2016, Stefan Schwarzer
    22# and ftputil contributors (see `doc/contributors.txt`)
    33# See the file LICENSE for licensing terms.
     
    1919    def test_to_bytes(self):
    2020        result = ftputil.tool.same_string_type_as(b"abc", "def")
    21         self.assertEqual(result, b"def")
    22         self.assertTrue(isinstance(result, compat.bytes_type))
     21        assert result == b"def"
     22        assert isinstance(result, compat.bytes_type)
    2323
    2424    def test_to_unicode(self):
    2525        result = ftputil.tool.same_string_type_as("abc", b"def")
    26         self.assertEqual(result, "def")
    27         self.assertTrue(isinstance(result, compat.unicode_type))
     26        assert result == "def"
     27        assert isinstance(result, compat.unicode_type)
    2828
    2929    def test_both_bytes_type(self):
    3030        result = ftputil.tool.same_string_type_as(b"abc", b"def")
    31         self.assertEqual(result, b"def")
    32         self.assertTrue(isinstance(result, compat.bytes_type))
     31        assert result == b"def"
     32        assert isinstance(result, compat.bytes_type)
    3333
    3434    def test_both_unicode_type(self):
    3535        result = ftputil.tool.same_string_type_as("abc", "def")
    36         self.assertEqual(result, "def")
    37         self.assertTrue(isinstance(result, compat.unicode_type))
     36        assert result == "def"
     37        assert isinstance(result, compat.unicode_type)
    3838
    3939
     
    4242    def test_as_bytes(self):
    4343        result = ftputil.tool.as_bytes(b"abc")
    44         self.assertEqual(result, b"abc")
    45         self.assertTrue(isinstance(result, compat.bytes_type))
     44        assert result == b"abc"
     45        assert isinstance(result, compat.bytes_type)
    4646        result = ftputil.tool.as_bytes("abc")
    47         self.assertEqual(result, b"abc")
    48         self.assertTrue(isinstance(result, compat.bytes_type))
     47        assert result == b"abc"
     48        assert isinstance(result, compat.bytes_type)
    4949       
    5050    def test_as_unicode(self):
    5151        result = ftputil.tool.as_unicode(b"abc")
    52         self.assertEqual(result, "abc")
    53         self.assertTrue(isinstance(result, compat.unicode_type))
     52        assert result == "abc"
     53        assert isinstance(result, compat.unicode_type)
    5454        result = ftputil.tool.as_unicode("abc")
    55         self.assertEqual(result, "abc")
    56         self.assertTrue(isinstance(result, compat.unicode_type))
     55        assert result == "abc"
     56        assert isinstance(result, compat.unicode_type)
    5757
    5858
     
    6262        string = "abc"
    6363        converted_string = ftputil.tool.encode_if_unicode(string, "latin1")
    64         self.assertTrue(isinstance(converted_string, compat.bytes_type))
     64        assert isinstance(converted_string, compat.bytes_type)
    6565
    6666    def test_dont_encode(self):
    6767        string = b"abc"
    6868        not_converted_string = ftputil.tool.encode_if_unicode(string, "latin1")
    69         self.assertEqual(string, not_converted_string)
    70         self.assertTrue(isinstance(not_converted_string, compat.bytes_type))
     69        assert string == not_converted_string
     70        assert isinstance(not_converted_string, compat.bytes_type)
    7171
    7272
Note: See TracChangeset for help on using the changeset viewer.