nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: joke2k/faker
Pull request #540 (2017-06-19 12:05:25)

Create a method for codes of cryptocurrencies in the currency provider


Patch:
diff --git a/faker/providers/currency/__init__.py b/faker/providers/currency/__init__.py
index 534bf481..d2e32aa5 100644
--- a/faker/providers/currency/__init__.py
+++ b/faker/providers/currency/__init__.py
@@ -170,6 +170,17 @@ class Provider(BaseProvider):
         "ZWD"
     )
 
+    # Source: https://en.wikipedia.org/wiki/List_of_cryptocurrencies
+    cryptocurrencies = (
+        'AMP', 'AUR', 'BC', 'BTC', 'BURST', 'DASH', 'DOGE', 'EMC', 'ETH',
+        'GRC', 'KOI', 'LTC', 'MSC', 'MZC', 'NMC', 'NXT', 'POT', 'PPC', 'SIL',
+        'TIT', 'VTC', 'XDN', 'XMR', 'XPM', 'XRP', 'ZEC',
+    )
+
     @classmethod
     def currency_code(cls):
         return cls.random_element(cls.currencies)
+
+    @classmethod
+    def cryptocurrency_code(cls):
+        return cls.random_element(cls.cryptocurrencies)


Test patch:
diff --git a/tests/providers/currency.py b/tests/providers/currency.py
new file mode 100644
index 00000000..c8ba3429
--- /dev/null
+++ b/tests/providers/currency.py
@@ -0,0 +1,15 @@
+import unittest
+
+from faker import Factory
+from faker.providers.currency import Provider as CurrencyProvider
+
+
+class TestCurrencyProvider(unittest.TestCase):
+    def setUp(self):
+        self.factory = Factory.create()
+
+    def test_cryptocurrency_code(self):
+        for _ in range(99):
+            code = self.factory.cryptocurrency_code()
+            self.assertIsInstance(code, str)
+            self.assertIn(code, CurrencyProvider.cryptocurrencies)
Repository: joke2k/faker
Pull request #554 (2017-07-12 08:45:33)

Adding an implementation of `local_regon` for pl_PL company provider.
An extension of REGON.


Patch:
diff --git a/faker/providers/company/pl_PL/__init__.py b/faker/providers/company/pl_PL/__init__.py
index af99b27b..a8d81a40 100644
--- a/faker/providers/company/pl_PL/__init__.py
+++ b/faker/providers/company/pl_PL/__init__.py
@@ -20,6 +20,24 @@ def regon_checksum(digits):
     return check_digit
 
 
+def local_regon_checksum(digits):
+    """
+    Calculates and returns a control digit for given list of digits basing on local REGON standard.
+    """
+    weights_for_check_digit = [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8]
+    check_digit = 0
+
+    for i in range(0, 13):
+        check_digit += weights_for_check_digit[i] * digits[i]
+
+    check_digit %= 11
+
+    if check_digit == 10:
+        check_digit = 0
+
+    return check_digit
+
+
 class Provider(CompanyProvider):
 
     @classmethod
@@ -39,3 +57,20 @@ class Provider(CompanyProvider):
         regon_digits.append(regon_checksum(regon_digits))
 
         return ''.join(str(digit) for digit in regon_digits)
+
+    @classmethod
+    def local_regon(cls):
+        """
+        Returns 14 character Polish National Business Registry Number,
+        local entity number.
+
+        https://pl.wikipedia.org/wiki/REGON
+        """
+        regon_digits = [int(digit) for digit in list(cls.regon())]
+
+        for _ in range(4):
+            regon_digits.append(cls.random_digit())
+
+        regon_digits.append(local_regon_checksum(regon_digits))
+
+        return ''.join(str(digit) for digit in regon_digits)


Test patch:
diff --git a/tests/providers/company.py b/tests/providers/company.py
index 9ec0ca29..62c864d4 100644
--- a/tests/providers/company.py
+++ b/tests/providers/company.py
@@ -9,7 +9,7 @@ from faker import Factory
 from faker.providers.company.hu_HU import Provider as HuProvider
 from faker.providers.company.ja_JP import Provider as JaProvider
 from faker.providers.company.pt_BR import Provider as PtProvider, company_id_checksum
-from faker.providers.company.pl_PL import Provider as PlProvider, regon_checksum
+from faker.providers.company.pl_PL import Provider as PlProvider, regon_checksum, local_regon_checksum
 from .. import string_types
 
 
@@ -85,3 +85,15 @@ class TestPlPL(unittest.TestCase):
     def test_regon(self):
         for _ in range(100):
             self.assertTrue(re.search(r'^\d{9}$', PlProvider.regon()))
+
+    def test_local_regon_checksum(self):
+        self.assertEquals(local_regon_checksum([1, 2, 3, 4, 5, 6, 7, 8, 5, 1, 2, 3, 4]), 7)
+        self.assertEquals(local_regon_checksum([6, 1, 1, 9, 4, 8, 8, 3, 2, 7, 5, 8, 0]), 3)
+        self.assertEquals(local_regon_checksum([8, 9, 2, 0, 0, 3, 6, 6, 0, 7, 0, 3, 2]), 3)
+        self.assertEquals(local_regon_checksum([3, 5, 7, 7, 1, 0, 2, 2, 2, 5, 4, 3, 3]), 0)
+        self.assertEquals(local_regon_checksum([9, 3, 5, 3, 1, 1, 0, 1, 2, 4, 8, 8, 2]), 1)
+
+    def test_local_regon(self):
+        for _ in range(100):
+            self.assertTrue(re.search(r'^\d{14}$', PlProvider.local_regon()))
+
Repository: joke2k/faker
Pull request #575 (2017-08-18 01:41:20)

Enable city suffixes.  Add section number. Add more city names.
The city names are taken from https://en.wikipedia.org/wiki/List_of_cities_in_Taiwan
The reference for the address format: https://en.wikipedia.org/wiki/Postal_addresses_in_Taiwan


Patch:
diff --git a/faker/providers/address/zh_TW/__init__.py b/faker/providers/address/zh_TW/__init__.py
index 16f5f706..99ad4ade 100644
--- a/faker/providers/address/zh_TW/__init__.py
+++ b/faker/providers/address/zh_TW/__init__.py
@@ -5,12 +5,11 @@ from .. import Provider as AddressProvider
 
 class Provider(AddressProvider):
     city_formats = ("{{city_name}}", )
-
     building_number_formats = ("%號", "%#號", "%##號", )
     postcode_formats = ("%####", "%##", )
-
-    street_address_formats = ("{{street_name}}{{street_name_suffix}}{{building_number}}", )
-
+    section_formats = ( "", "", "", "", "%段", )
+    street_address_formats = ( "{{street_name}}{{street_name_suffix}}{{section_number}}{{building_number}}", )
+    city_formats = ( "{{city_name}}{{city_name_suffix}}", )
     address_formats = ("{{postcode}} {{city}}{{street_address}}{{secondary_address}}", )
     secondary_address_formats = ('#樓', '之#')
 
@@ -39,11 +38,21 @@ class Provider(AddressProvider):
 
     street_suffixes = ( "路", "街", "巷" )
 
-    cities = ("基隆市", "台北市", "新北市", "桃園縣", "新竹市",
-              "新竹縣", "苗栗縣", "台中市", "彰化縣", "南投縣",
-              "雲林縣", "嘉義市", "嘉義縣", "台南市", "高雄市",
-              "屏東縣", "台東縣", "花蓮縣", "宜蘭縣", "澎湖縣",
-              "金門縣", "連江縣")
+    cities = ("基隆", "台北", "新北", "桃園", "新竹",
+              "新竹", "苗栗", "台中", "彰化", "南投",
+              "雲林", "嘉義", "桃園", "台南", "高雄",
+              "屏東", "台東", "花蓮", "宜蘭", "澎湖",
+              "金門", "連江", "太保", "朴子", "馬公",
+              "頭份", "臺東", "斗六", "員林", "竹北",
+              "平鎮", "臺中", "八德", "板橋", "大里",
+              "鳳山", "豐原", "蘆洲", "蘆竹", "三重",
+              "樹林", "太平", "新營", "新營", "汐止",
+              "楊梅", "永和", "永康", "中和", "中壢",
+              "阿里山", "白沙", "褒忠", "北斗", "北竿",
+              "北港", "卑南", "草屯", "梅山", "牡丹",
+              "橫山", "光復", "關山", "古坑", "竹田")
+
+    city_suffixes = ( "市", "縣" )
 
     # from
     countries = ("阿爾巴尼亞", "剛果共和國", "阿爾及利亞", "丹麥",
@@ -98,3 +107,11 @@ class Provider(AddressProvider):
     @classmethod
     def city_name(cls):
         return cls.random_element(cls.cities)
+
+    @classmethod
+    def city_name_suffix(cls):
+        return cls.random_element(cls.city_suffixes)
+
+    @classmethod
+    def section_number(cls):
+        return cls.numerify(cls.random_element(cls.section_formats))


Test patch:
diff --git a/tests/providers/address.py b/tests/providers/address.py
index 7ef5326c..eec22d6a 100644
--- a/tests/providers/address.py
+++ b/tests/providers/address.py
@@ -153,3 +153,6 @@ class TestZhTW(unittest.TestCase):
 
         city = self.factory.city()
         assert isinstance(city, string_types)
+
+        section = self.factory.section_number()
+        assert isinstance(section, string_types)
Repository: joke2k/faker
Pull request #580 (2017-08-28 08:11:38)

Add ko_KR datetime
added the datetime provider for ko_KR.


Patch:
diff --git a/faker/providers/date_time/ko_KR/__init__.py b/faker/providers/date_time/ko_KR/__init__.py
new file mode 100644
index 00000000..f3333b74
--- /dev/null
+++ b/faker/providers/date_time/ko_KR/__init__.py
@@ -0,0 +1,40 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .. import Provider as DateTimeProvider
+
+
+class Provider(DateTimeProvider):
+
+    @classmethod
+    def day_of_week(cls):
+        day = cls.date('%w')
+        DAY_NAMES = {
+            "0": "일요일",
+            "1": "월요일",
+            "2": "화요일",
+            "3": "수요일",
+            "4": "목요일",
+            "5": "금요일",
+            "6": "토요일",
+        }
+        return DAY_NAMES[day]
+
+    @classmethod
+    def month_name(cls):
+        month = cls.month()
+        MONTH_NAMES = {
+            "01": "1월",
+            "02": "2월",
+            "03": "3월",
+            "04": "4월",
+            "05": "5월",
+            "06": "6월",
+            "07": "7월",
+            "08": "8월",
+            "09": "9월",
+            "10": "10월",
+            "11": "11월",
+            "12": "12월",
+        }
+        return MONTH_NAMES[month]


Test patch:
diff --git a/tests/providers/date_time.py b/tests/providers/date_time.py
index 8371dc10..5c184bbd 100644
--- a/tests/providers/date_time.py
+++ b/tests/providers/date_time.py
@@ -9,6 +9,7 @@ import unittest
 from faker import Factory
 from faker.generator import random
 from faker.providers.date_time import Provider as DatetimeProvider
+from faker.providers.date_time.ko_KR import Provider as koKRProvider
 from .. import string_types
 
 
@@ -32,6 +33,18 @@ class UTC(tzinfo):
 
 utc = UTC()
 
+class TestKoKR(unittest.TestCase):
+
+    def setUp(self):
+        self.factory = Factory.create('ko_KR')
+
+    def test_day(self):
+        day = self.factory.day_of_week()
+        assert isinstance(day, string_types)
+    def test_month(self):
+        month = self.factory.month()
+        assert isinstance(month, string_types)
+
 
 class TestDateTime(unittest.TestCase):
Repository: joke2k/faker
Pull request #600 (2017-09-14 20:34:50)

Phone test refactor


Patch:
diff --git a/faker/providers/phone_number/__init__.py b/faker/providers/phone_number/__init__.py
index 1af2d2d2..7dfafdf4 100644
--- a/faker/providers/phone_number/__init__.py
+++ b/faker/providers/phone_number/__init__.py
@@ -6,5 +6,13 @@ from .. import BaseProvider
 class Provider(BaseProvider):
     formats = ('###-###-###',)
 
+    msisdn_formats = (
+        '#############',
+    )
+
     def phone_number(self):
         return self.numerify(self.random_element(self.formats))
+
+    def msisdn(self):
+        """ https://en.wikipedia.org/wiki/MSISDN """
+        return self.numerify(self.random_element(self.msisdn_formats))
diff --git a/faker/providers/phone_number/pt_BR/__init__.py b/faker/providers/phone_number/pt_BR/__init__.py
index c8609182..95707ba6 100644
--- a/faker/providers/phone_number/pt_BR/__init__.py
+++ b/faker/providers/phone_number/pt_BR/__init__.py
@@ -81,7 +81,3 @@ class Provider(PhoneNumberProvider):
         '5571#########',
         '5581#########',
     )
-
-    def msisdn(self):
-        """ https://en.wikipedia.org/wiki/MSISDN """
-        return self.numerify(self.random_element(self.msisdn_formats))


Test patch:
diff --git a/tests/providers/test_phone_number.py b/tests/providers/test_phone_number.py
index 511390f7..f3cb107d 100644
--- a/tests/providers/test_phone_number.py
+++ b/tests/providers/test_phone_number.py
@@ -4,18 +4,25 @@ from __future__ import unicode_literals
 
 import unittest
 
-from faker import Factory
+from faker import Faker
 from .. import string_types
 
 
-class TestJaJP(unittest.TestCase):
+class TestPhoneNumber(unittest.TestCase):
     """ Tests phone_number in the ja_JP locale """
 
     def setUp(self):
-        self.factory = Factory.create('ja')
+        self.factory = Faker()
 
     def test_phone_number(self):
         pn = self.factory.phone_number()
+
+        assert pn
+        assert isinstance(pn, string_types)
+
+    def test_phone_number_ja(self):
+        factory = Faker('ja')
+        pn = factory.phone_number()
         formats = ('070', '080', '090')
 
         assert pn
@@ -36,15 +43,17 @@ class TestJaJP(unittest.TestCase):
             assert len(third) == 4
             assert first in formats
 
-
-class TestMSISDN(unittest.TestCase):
-    """ Tests MSISDN in the pt_br locale """
-
-    def setUp(self):
-        self.factory = Factory.create('pt_br')
-
     def test_msisdn(self):
         msisdn = self.factory.msisdn()
+
+        assert msisdn is not None
+        assert isinstance(msisdn, string_types)
+        assert len(msisdn) == 13
+        assert msisdn.isdigit()
+
+    def test_msisdn_pt_br(self):
+        factory = Faker('pt_br')
+        msisdn = factory.msisdn()
         formats = ('5511', '5521', '5531', '5541', '5551', '5561', '5571', '5581')
 
         assert msisdn is not None
Repository: joke2k/faker
Pull request #614 (2017-09-29 17:40:41)

Fix date_time.time_series() to ensure start and end bounds are inclusive
* Fix for issue #613
* Includes update to regression tests

@fcurella 


Patch:
diff --git a/faker/providers/date_time/__init__.py b/faker/providers/date_time/__init__.py
index 76aa6723..a43fdaf8 100644
--- a/faker/providers/date_time/__init__.py
+++ b/faker/providers/date_time/__init__.py
@@ -726,8 +726,8 @@ class Provider(BaseProvider):
 
         datapoint = start_date
         while datapoint < end_date:
-            datapoint += precision
             dt = timestamp_to_datetime(datapoint, tzinfo)
+            datapoint += precision
             yield (dt, distrib(dt))
 
     def am_pm(self):


Test patch:
diff --git a/tests/providers/test_date_time.py b/tests/providers/test_date_time.py
index 7c0cd5c6..5a496a1e 100644
--- a/tests/providers/test_date_time.py
+++ b/tests/providers/test_date_time.py
@@ -354,6 +354,13 @@ class TestDateTime(unittest.TestCase):
         self.assertTrue(len(series), 7)
         self.assertTrue(series[1][0] - series[0][0], timedelta(days=1))
 
+        # avoid microseconds as provider's internal parsing uses POSIX timestamps which only have second granularity
+        end = datetime.now(utc).replace(microsecond=0)
+        start = end - timedelta(days=15)
+
+        series = [i for i in self.factory.time_series(start_date=start, end_date=end, tzinfo=start.tzinfo)]
+        self.assertEqual(series[0][0], start)
+
 
 class TestPlPL(unittest.TestCase):
Repository: joke2k/faker
Pull request #615 (2017-10-01 23:34:49)

Create a provider to Brazilian license plates


Patch:
diff --git a/faker/providers/automotive/pt_BR/__init__.py b/faker/providers/automotive/pt_BR/__init__.py
new file mode 100644
index 00000000..cc991920
--- /dev/null
+++ b/faker/providers/automotive/pt_BR/__init__.py
@@ -0,0 +1,11 @@
+# coding=utf-8
+from __future__ import unicode_literals
+
+from .. import Provider as AutomotiveProvider
+
+
+class Provider(AutomotiveProvider):
+
+    license_formats = (
+        '???-####',
+    )


Test patch:
diff --git a/tests/providers/test_automotive.py b/tests/providers/test_automotive.py
new file mode 100644
index 00000000..66d0d02c
--- /dev/null
+++ b/tests/providers/test_automotive.py
@@ -0,0 +1,20 @@
+# coding=utf-8
+from __future__ import unicode_literals
+
+import re
+import unittest
+
+from faker import Factory
+from six import string_types
+
+
+class TestPtBR(unittest.TestCase):
+
+    def setUp(self):
+        self.factory = Factory.create('pt_BR')
+        self.format = re.compile('[\w]{3}-[\d]{4}')
+
+    def test_plate_has_been_generated(self):
+        plate = self.factory.license_plate()
+        assert isinstance(plate, string_types)
+        assert self.format.match(plate)
Repository: joke2k/faker
Pull request #636 (2017-10-23 11:55:47)

Add aliases to make pt_BR address provider compatible with en_US


Patch:
diff --git a/faker/providers/address/pt_BR/__init__.py b/faker/providers/address/pt_BR/__init__.py
index c46fcc76..3c50ba22 100644
--- a/faker/providers/address/pt_BR/__init__.py
+++ b/faker/providers/address/pt_BR/__init__.py
@@ -236,3 +236,13 @@ class Provider(AddressProvider):
         :example 'Serra'
         """
         return self.random_element(self.bairros)
+
+    # aliases
+    def neighborhood(self):
+        return self.bairro()
+
+    def state(self):
+        return self.estado_nome()
+
+    def state_abbr(self):
+        return self.estado_sigla()


Test patch:
diff --git a/tests/providers/test_address.py b/tests/providers/test_address.py
index b92f864b..af0aaf46 100644
--- a/tests/providers/test_address.py
+++ b/tests/providers/test_address.py
@@ -339,6 +339,7 @@ class TestZhTW(unittest.TestCase):
         address = self.factory.address()
         assert isinstance(address, string_types)
 
+
 class TestZhCN(unittest.TestCase):
     """ Tests addresses in the zh_cn locale """
 
@@ -366,3 +367,31 @@ class TestZhCN(unittest.TestCase):
 
         for _ in range(100):
             self.assertTrue(re.match(r'\d{5}', self.factory.postcode()))
+
+
+class TestPtBr(unittest.TestCase):
+
+    def setUp(self):
+        self.factory = Faker('pt_BR')
+
+    def test_address(self):
+        country = self.factory.country()
+        assert isinstance(country, string_types)
+
+        street = self.factory.street_name()
+        assert isinstance(street, string_types)
+
+        city = self.factory.street_address()
+        assert isinstance(city, string_types)
+
+        neighborhood = self.factory.neighborhood()
+        assert isinstance(neighborhood, string_types)
+
+        state = self.factory.state()
+        assert isinstance(state, string_types)
+
+        state_abbr = self.factory.state_abbr()
+        assert isinstance(state_abbr, string_types)
+
+        address = self.factory.address()
+        assert isinstance(address, string_types)
Repository: joke2k/faker
Pull request #720 (2018-03-10 19:50:14)

Add latitude and longitude to Austria Provider
### What does this changes

Geo coordinates in the area from Austria.
Latitude and Longitude for the de_AT provider.




Patch:
diff --git a/faker/providers/address/de_AT/__init__.py b/faker/providers/address/de_AT/__init__.py
index 2fd9bbdc..e27f7641 100644
--- a/faker/providers/address/de_AT/__init__.py
+++ b/faker/providers/address/de_AT/__init__.py
@@ -149,4 +149,10 @@ class Provider(AddressProvider):
         return self.random_element(self.cities)
 
     def state(self):
-        return self.random_element(self.states)
\ No newline at end of file
+        return self.random_element(self.states)
+
+    def latitude(self):
+        return self.geo_coordinate(center=47.60707, radius=1)
+
+    def longitude(self):
+        return self.geo_coordinate(center=13.37208, radius=2)


Test patch:
diff --git a/tests/providers/test_address.py b/tests/providers/test_address.py
index 513a6443..5286cd36 100644
--- a/tests/providers/test_address.py
+++ b/tests/providers/test_address.py
@@ -57,6 +57,14 @@ class TestDeAT(unittest.TestCase):
         postcode = self.factory.postcode()
         assert re.match("\d{4}", postcode)
 
+    def test_latitude(self):
+        latitude = self.factory.latitude()
+        assert re.match("4[6-8]\.\d+", str(latitude))
+
+    def test_longitude(self):
+        longitude = self.factory.longitude()
+        assert re.match("1[1-5]\.\d+", str(longitude))
+
 
 class TestDeDE(unittest.TestCase):
     """ Tests in addresses in the de_DE locale """
Repository: joke2k/faker
Pull request #726 (2018-03-13 15:19:09)

NEW: Added Norwegian no_NO bank provider
11 digits. 

### What does this changes

Norwegian bank accounts have 11 digits: https://www.ecbs.org/iban/norway-bank-account-number.html

1-4: Bank identifier
5-10: Account identifier
11: Control digit

### What was wrong

Even with no_NO locale, calls to fake.bban() returned en_GB account numbers.

### How this fixes it

Returns 11 digits. No check for bank identifier (first 4 digits) or control digit (last digit).



Patch:
diff --git a/faker/providers/bank/no_NO/__init__.py b/faker/providers/bank/no_NO/__init__.py
new file mode 100644
index 00000000..10126e15
--- /dev/null
+++ b/faker/providers/bank/no_NO/__init__.py
@@ -0,0 +1,5 @@
+from .. import Provider as BankProvider
+
+class Provider(BankProvider):
+    bban_format = '###########'
+    country_code = 'NO'


Test patch:
diff --git a/tests/providers/test_bank.py b/tests/providers/test_bank.py
new file mode 100644
index 00000000..97516364
--- /dev/null
+++ b/tests/providers/test_bank.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+import re
+import unittest
+
+from faker import Faker
+
+class TestNoNO(unittest.TestCase):
+    """ Tests the bban in no_NO locale """
+
+    def setUp(self):
+        self.factory = Faker('no_NO')
+
+    def test_bban(self):
+        bban = self.factory.bban()
+        assert re.match("\d{11}", bban)
Repository: joke2k/faker
Pull request #738 (2018-04-06 13:01:29)

Added Unix device & partition
### What does this changes

I added:
- File.unix_device : To create Unix device path. ie: /dev/sda, /dev/xvde, etc
- File.unix_partition: To create Unix partition path. ie: /dev/vdc1, /dev/sdb1, etc

With tests, of course ;)


Patch:
diff --git a/faker/providers/file/__init__.py b/faker/providers/file/__init__.py
index a6ab2777..594151cd 100644
--- a/faker/providers/file/__init__.py
+++ b/faker/providers/file/__init__.py
@@ -1,5 +1,7 @@
 # coding=utf-8
 from __future__ import unicode_literals
+
+import string
 from collections import OrderedDict
 
 from .. import BaseProvider
@@ -187,6 +189,7 @@ class Provider(BaseProvider):
         ("text", text_file_extensions),
         ("video", video_file_extensions),
     ))
+    unix_device_prefixes = ('sd', 'vd', 'xvd',)
 
     def mime_type(self, category=None):
         """
@@ -224,3 +227,20 @@ class Provider(BaseProvider):
         for d in range(0, depth):
             path = "/{0}{1}".format(self.generator.word(), path)
         return path
+
+    def unix_device(self, prefix=None):
+        """
+        :param prefix: sd|vd|xvd
+        """
+        prefix = prefix or self.random_element(self.unix_device_prefixes)
+        suffix = self.random_element(string.ascii_lowercase)
+        path = '/dev/%s%s' % (prefix, suffix)
+        return path
+
+    def unix_partition(self, prefix=None):
+        """
+        :param prefix: sd|vd|xvd
+        """
+        path = self.unix_device(prefix=prefix)
+        path += str(self.random_digit())
+        return path


Test patch:
diff --git a/tests/providers/test_file.py b/tests/providers/test_file.py
index cca458d0..767d48ec 100644
--- a/tests/providers/test_file.py
+++ b/tests/providers/test_file.py
@@ -22,3 +22,27 @@ class TestFile(unittest.TestCase):
             self.assertTrue(re.search(r'\/\w+\/\w+\.pdf', file_path))
             file_path = self.factory.file_path(category='image')
             self.assertTrue(re.search(r'\/\w+\/\w+\.(bmp|gif|jpeg|jpg|png|tiff)', file_path))
+
+    def test_unix_device(self):
+        reg_device = re.compile('^/dev/(vd|sd|xvd)[a-z]$')
+        # Test default
+        for _ in range(100):
+            path = self.factory.unix_device()
+            self.assertTrue(reg_device.match(path))
+        # Test with prefix
+        for _ in range(100):
+            path = self.factory.unix_device('sd')
+            self.assertTrue(reg_device.match(path))
+            self.assertTrue(path.startswith('/dev/sd'))
+
+    def test_unix_partition(self):
+        reg_part = re.compile('^/dev/(vd|sd|xvd)[a-z]\d$')
+        # Test default
+        for _ in range(100):
+            path = self.factory.unix_partition()
+            self.assertTrue(reg_part.match(path))
+        # Test with prefix
+        for _ in range(100):
+            path = self.factory.unix_partition('sd')
+            self.assertTrue(reg_part.match(path))
+            self.assertTrue(path.startswith('/dev/sd'))