from __future__ import unicode_literals

import unittest
import re

from faker import Factory
from faker.utils import text
from .. import string_types


class ne_NP_FactoryTestCase(unittest.TestCase):
  
    def setUp(self):
      self.factory = Factory.create('ne_NP')
        
    def test_address(self):
      from faker.providers.address.ne_NP import Provider
      countries = Provider.countries
      country   = self.factory.country()
      assert country
      assert isinstance(country, string_types)
      assert country in countries
      
      districts = Provider.districts
      district  = self.factory.district()
      assert district
      assert isinstance(district, string_types)
      assert district in districts

      cities = Provider.cities
      city   = self.factory.city()
      assert city
      assert isinstance(city, string_types)
      assert city in cities
      
    def test_names(self):
      from faker.providers.person.ne_NP import Provider
      first_names = Provider.first_names
      name = self.factory.name()
      first_name, last_name = name.split()
      assert first_name
      assert isinstance(first_name, string_types)
      assert first_name in first_names
      
      last_names = Provider.last_names
      assert last_names
      assert isinstance(last_name, string_types)
      assert last_name in last_names
      
      
      
from __future__ import unicode_literals

import unittest

from faker import Factory
from .. import string_types


class NeNPFactoryTestCase(unittest.TestCase):

    def setUp(self):
        self.factory = Factory.create('ne_NP')
        
    def test_address(self):
        from faker.providers.address.ne_NP import Provider
        country = self.factory.country()
        assert isinstance(country, string_types)
        assert country in Provider.countries

        district = self.factory.district()
        assert isinstance(district, string_types)
        assert district in Provider.districts

        city = self.factory.city()
        assert isinstance(city, string_types)
        assert city in Provider.cities

    def test_names(self):
        from faker.providers.person.ne_NP import Provider
        for _ in range(10000):
            name = self.factory.name().split()
            assert all(isinstance(n, string_types) for n in name)
            # name should always be 2-3 words. If 3, first word
            # should be a prefix.
            assert name[-2] in Provider.first_names
            assert name[-1] in Provider.last_names
            prefixes = Provider.prefixes_male + Provider.prefixes_female
            if len(name) == 3:
                assert name[0] in prefixes

Fix incorrect ne_NP locale tests
Fix incorrect ne_NP locale tests

This test incorrectly assumes a call to name() will
yield only a first/last name, which isn't always true for this
locale. I suspect it hasn't been uncovered yet because the
tests are seeded the same at the beginning of every run. It only
becomes a problem when you start moving tests around. This change
addresses the incorrect assertions as well as makes the file PEP8
compliant.

  from __future__ import unicode_literals
  
  import unittest
- import re
  
  from faker import Factory
- from faker.utils import text
  from .. import string_types
  
  
- class ne_NP_FactoryTestCase(unittest.TestCase):
+ class NeNPFactoryTestCase(unittest.TestCase):
-   
+ 
      def setUp(self):
-       self.factory = Factory.create('ne_NP')
+         self.factory = Factory.create('ne_NP')
          
      def test_address(self):
-       from faker.providers.address.ne_NP import Provider
+         from faker.providers.address.ne_NP import Provider
-       countries = Provider.countries
-       country   = self.factory.country()
+         country = self.factory.country()
-       assert country
-       assert isinstance(country, string_types)
+         assert isinstance(country, string_types)
-       assert country in countries
+         assert country in Provider.countries
-       
-       districts = Provider.districts
-       district  = self.factory.district()
-       assert district
-       assert isinstance(district, string_types)
-       assert district in districts
  
-       cities = Provider.cities
+         district = self.factory.district()
+         assert isinstance(district, string_types)
+         assert district in Provider.districts
+ 
-       city   = self.factory.city()
+         city = self.factory.city()
-       assert city
-       assert isinstance(city, string_types)
+         assert isinstance(city, string_types)
-       assert city in cities
+         assert city in Provider.cities
-       
+ 
      def test_names(self):
-       from faker.providers.person.ne_NP import Provider
+         from faker.providers.person.ne_NP import Provider
-       first_names = Provider.first_names
+         for _ in range(10000):
-       name = self.factory.name()
+             name = self.factory.name().split()
+             assert all(isinstance(n, string_types) for n in name)
+             # name should always be 2-3 words. If 3, first word
+             # should be a prefix.
+             assert name[-2] in Provider.first_names
-       first_name, last_name = name.split()
-       assert first_name
-       assert isinstance(first_name, string_types)
-       assert first_name in first_names
-       
-       last_names = Provider.last_names
+             assert name[-1] in Provider.last_names
+             prefixes = Provider.prefixes_male + Provider.prefixes_female
+             if len(name) == 3:
+                 assert name[0] in prefixes
+ 
-       assert last_names
-       assert isinstance(last_name, string_types)
-       assert last_name in last_names
-       
-       
-       
Fix incorrect ne_NP locale tests
## Code Before:
from __future__ import unicode_literals

import unittest
import re

from faker import Factory
from faker.utils import text
from .. import string_types


class ne_NP_FactoryTestCase(unittest.TestCase):
  
    def setUp(self):
      self.factory = Factory.create('ne_NP')
        
    def test_address(self):
      from faker.providers.address.ne_NP import Provider
      countries = Provider.countries
      country   = self.factory.country()
      assert country
      assert isinstance(country, string_types)
      assert country in countries
      
      districts = Provider.districts
      district  = self.factory.district()
      assert district
      assert isinstance(district, string_types)
      assert district in districts

      cities = Provider.cities
      city   = self.factory.city()
      assert city
      assert isinstance(city, string_types)
      assert city in cities
      
    def test_names(self):
      from faker.providers.person.ne_NP import Provider
      first_names = Provider.first_names
      name = self.factory.name()
      first_name, last_name = name.split()
      assert first_name
      assert isinstance(first_name, string_types)
      assert first_name in first_names
      
      last_names = Provider.last_names
      assert last_names
      assert isinstance(last_name, string_types)
      assert last_name in last_names
      
      
      
## Instruction:
Fix incorrect ne_NP locale tests
## Code After:
from __future__ import unicode_literals

import unittest

from faker import Factory
from .. import string_types


class NeNPFactoryTestCase(unittest.TestCase):

    def setUp(self):
        self.factory = Factory.create('ne_NP')
        
    def test_address(self):
        from faker.providers.address.ne_NP import Provider
        country = self.factory.country()
        assert isinstance(country, string_types)
        assert country in Provider.countries

        district = self.factory.district()
        assert isinstance(district, string_types)
        assert district in Provider.districts

        city = self.factory.city()
        assert isinstance(city, string_types)
        assert city in Provider.cities

    def test_names(self):
        from faker.providers.person.ne_NP import Provider
        for _ in range(10000):
            name = self.factory.name().split()
            assert all(isinstance(n, string_types) for n in name)
            # name should always be 2-3 words. If 3, first word
            # should be a prefix.
            assert name[-2] in Provider.first_names
            assert name[-1] in Provider.last_names
            prefixes = Provider.prefixes_male + Provider.prefixes_female
            if len(name) == 3:
                assert name[0] in prefixes
