Repository: joke2k/faker

Issue:
Error in Provider date_time for method fake.date() colliding with faker.date_time.date()
* Faker version: 4.02
* OS: MAC, LINUX

Brief summary of the issue goes here.
The documenation for the date_time provider for the function 

`fake.date(pattern='%Y-%m-%d', end_datetime=None)` 

 Returning 

> Exception has occurred: TypeError
> function missing required argument 'year' (pos 1)
>   File "/Users/test/test-py/faker_test.py", line 15, in <module>
>     date = fake.date(pattern='%Y-%m-%d', end_datetime=None)

Which I think is clashing with the signature for:

```
class datetime(real_datetime):
    def strftime(self, fmt):
        return strftime(self, fmt)

    def combine(self, date, time):
        return datetime(date.year, date.month, date.day,
                        time.hour, time.minute, time.microsecond,
                        time.tzinfo)

    def date(self):        <===============================
        return date(self.year, self.month, self.day)

```

### Steps to reproduce

```
from faker import Faker
from faker.providers import ( date_time)

fake = Faker()
fake.add_provider(date_time)
date = fake.date(pattern='%Y-%m-%d', end_datetime=None)
```

### Expected behavior

Should produce a random string
# '2000-07-13'

### Actual behavior

> Exception has occurred: TypeError
> function missing required argument 'year' (pos 1)
>   File "/Users/test/test-py/faker_test.py", line 15, in <module>
>     date = fake.date(pattern='%Y-%m-%d', end_datetime=None)




Discussion:
+1 
I reproduce the problem with both 4.0.2 and 3.0.1 version of pytest

Resolving patch:
diff --git a/faker/providers/date_time/__init__.py b/faker/providers/date_time/__init__.py
--- a/faker/providers/date_time/__init__.py
+++ b/faker/providers/date_time/__init__.py
@@ -1,7 +1,9 @@
 import re
 
 from calendar import timegm
-from datetime import MAXYEAR, date, datetime, timedelta
+from datetime import MAXYEAR
+from datetime import date as dtdate
+from datetime import datetime, timedelta
 
 from dateutil import relativedelta
 from dateutil.tz import gettz, tzlocal, tzutc
@@ -1542,7 +1544,7 @@ def _parse_timedelta(cls, value):
 
     @classmethod
     def _parse_date_time(cls, value, tzinfo=None):
-        if isinstance(value, (datetime, date)):
+        if isinstance(value, (datetime, dtdate)):
             return datetime_to_timestamp(value)
         now = datetime.now(tzinfo)
         if isinstance(value, timedelta):
@@ -1560,9 +1562,9 @@ def _parse_date_time(cls, value, tzinfo=None):
     def _parse_date(cls, value):
         if isinstance(value, datetime):
             return value.date()
-        elif isinstance(value, date):
+        elif isinstance(value, dtdate):
             return value
-        today = date.today()
+        today = dtdate.today()
         if isinstance(value, timedelta):
             return today + value
         if isinstance(value, str):
@@ -1850,9 +1852,9 @@ def date_this_century(self, before_today=True, after_today=False):
         :example Date('2012-04-04')
         :return Date
         """
-        today = date.today()
-        this_century_start = date(today.year - (today.year % 100), 1, 1)
-        next_century_start = date(this_century_start.year + 100, 1, 1)
+        today = dtdate.today()
+        this_century_start = dtdate(today.year - (today.year % 100), 1, 1)
+        next_century_start = dtdate(this_century_start.year + 100, 1, 1)
 
         if before_today and after_today:
             return self.date_between_dates(
@@ -1873,9 +1875,9 @@ def date_this_decade(self, before_today=True, after_today=False):
         :example Date('2012-04-04')
         :return Date
         """
-        today = date.today()
-        this_decade_start = date(today.year - (today.year % 10), 1, 1)
-        next_decade_start = date(this_decade_start.year + 10, 1, 1)
+        today = dtdate.today()
+        this_decade_start = dtdate(today.year - (today.year % 10), 1, 1)
+        next_decade_start = dtdate(this_decade_start.year + 10, 1, 1)
 
         if before_today and after_today:
             return self.date_between_dates(this_decade_start, next_decade_start)
@@ -1895,9 +1897,9 @@ def date_this_year(self, before_today=True, after_today=False):
         :example Date('2012-04-04')
         :return Date
         """
-        today = date.today()
+        today = dtdate.today()
         this_year_start = today.replace(month=1, day=1)
-        next_year_start = date(today.year + 1, 1, 1)
+        next_year_start = dtdate(today.year + 1, 1, 1)
 
         if before_today and after_today:
             return self.date_between_dates(this_year_start, next_year_start)
@@ -1918,7 +1920,7 @@ def date_this_month(self, before_today=True, after_today=False):
         :example DateTime('2012-04-04 11:02:02')
         :return DateTime
         """
-        today = date.today()
+        today = dtdate.today()
         this_month_start = today.replace(day=1)
 
         next_month_start = this_month_start + \


Test patch:
diff --git a/tests/providers/test_date_time.py b/tests/providers/test_date_time.py
--- a/tests/providers/test_date_time.py
+++ b/tests/providers/test_date_time.py
@@ -83,6 +83,12 @@ def assertBetween(self, date, start_date, end_date):
         assert date <= end_date
         assert date >= start_date
 
+    def test_date(self):
+        date_format = '%Y-%m-%d'
+        date_string = self.fake.date(pattern=date_format)
+        assert isinstance(date_string, str)
+        assert isinstance(datetime.strptime(date_string, date_format), datetime)
+
     def test_day(self):
         day = self.fake.day_of_week()
         assert isinstance(day, str)