Пример #1
0
 def test_null(self):
     testcase = ""
     expected = ""
     self.assertEqual(rearrange_name(testcase), expected)
Пример #2
0
 def test_empty(self):
     testcase = ''
     expected = ''
     self.assertEqual(rearrange_name(testcase),expected)
Пример #3
0
 def test_one_name(self):
     testcase = 'Voltare'
     expected = 'Voltare'
     self.assertEqual(rearrange_name(testcase),expected)      
Пример #4
0
 def test_basic(self):
     testcase = "Lovelace, Ada"
     expected = "Ada Lovelace"
     self.assertEqual(rearrange_name(testcase), expected)#this method provided to us by the TestCase class we inhereted from to verify
Пример #5
0
 def test_one_name(self):
     testcase = "Voltaire"
     expected = "Voltaire"
     self.assertEqual(rearrange_name(testcase), expected)
Пример #6
0
 def double_name(self):
     testcase = 'Hridoy, Rakib H.'
     expected = 'Rakib H. Hridoy'
     self.assertEqual(rearrange_name(testcase), expected)
Пример #7
0
 def test_empty(self):
     test_case = ""
     expected = ""
     self.assertEqual(rearrange_name(test_case), expected)
Пример #8
0
 def test_isnumeric(self):
     testcase = "1"
     self.assertRaises(TypeError, rearrange_name(testcase))
Пример #9
0
 def test_double_name(self):
     testcase = "Imawanto, Renard I."
     expected = "Renard I. Imawanto"
     self.assertEqual(rearrange_name(testcase), expected)
Пример #10
0
 def single(self):
     testcase = "Plato"
     expected = "Plato"
     self.assertEqual(rearrange.rearrange_name(testcase), expected)
Пример #11
0
 def test_single_name(self):
     testcase = "Siegfried"
     expected = "Siegfried"
     self.assertEqual(rearrange_name(testcase), expected)
 def test_basic(self):
     testcase = "Mathew, Pius"
     expected = "Pius, Mathew"
     self.assertEqual(rearrange_name(testcase), expected)
 def test_one_name(self):
     testcase = "Mathew"
     expected = "Mathew"
     self.assertEqual(rearrange_name(testcase), expected)
Пример #14
0
 def test_basic(self):
     testcase = 'Guenon, Rene'
     expected = 'Rene Guenon'
     self.assertEqual(rearrange_name(testcase), expected)
 def test_one_name(self):
     testCase = "Axel"
     expected = "Axel"
     self.assertEqual(rearrange_name(testCase), expected)
Пример #16
0
def test_basic(self):
    testcase = "michael ,shanmuk"
    expected = "Shanmuk Michael"
    self.assertEqual(rearrange_name(testcase), expected)
"""
#%%
"""
here I am re-phrasing the code in order to use the Match Object x 
the function "rearrange_name" changes the sequence of the surname, name into name,surname
"""
import re


def rearrange_name(name):
    x = re.search(r"^([\w .]*), ([\w .]*)$", name)
    print("{} {}".format(x[2], x[1]))


rearrange_name(
    "Lovelace, Ada"
)  # I wrote this argument MANUALLY!! I am calling the function "rearrange_name" by providing the argument Lovelace,Ada

# Output is; Ada Lovelace, so perfect, it works
#%%
"""
EXAMPLE 1b

we will use the keyword "from" in the Linux OS command line
this way we can use the function rearrange_name at the command line, and ofcourse test it by providing an argument

in Linux OS command line write: 
#python3
#from rearrange import rearrange_name

as we see the rearrange is the MODULE that contains the rearrange_name FUNCTION
Пример #18
0
def test_double_name(self):
    testcase = "is Good, P.Shanmuk"
    expected = "P.Shanmuk is Good"
    self.assertEqual(rearrange_name(testcase), expected)
 def test_one_name(self):
     testcase = 'Socrates'
     expected = 'Socrates'
     self.assertEqual(rearrange_name(testcase), expected)
Пример #20
0
def test_double_name(self):
    testcase = "Shanmuk"
    expected = "Shanmuk"
    self.assertEqual(rearrange_name(testcase), expected)
Пример #21
0
 def test_one_name(self):
     testcase = "Shubham"
     expected = "Shubham"
     self.assertEqual(rearrange_name(testcase), expected)
Пример #22
0
from rearrange import rearrange_name
### manual test ###
print(rearrange_name("Jacky, Chaan"))
Пример #23
0
 def test_double_name(self):
     testcase = "Hopper, Grace M."
     expected = "Grace M. Hopper"
     self.assertEqual(rearrange_name(testcase), expected)
Пример #24
0
 def test_single_name(self):
     testcase = "Madonna"
     expected = "Madonna"
     self.assertEqual(rearrange_name(testcase), expected)
Пример #25
0
 def test_basic(self):
     testcase = "Lovelace, Ada"
     expected = "Ada Lovelace"
     self.assertEqual(rearrange_name(testcase), expected)
Пример #26
0
 def test_one_name(self):
     testcase = "Srilakshmi"
     expected = "Srilakshmi"
     self.assertEqual(rearrange_name(testcase), expected)
Пример #27
0
 def test_double_name(self):
     testcase = 'Hopper, Grace M.'
     expected = 'Grace M. Hopper'
     self.assertEqual(rearrange_name(testcase),expected)        
Пример #28
0
 def test_basic(self):
     testcase = "Srilakshmi, Maddali"
     expected = "Maddali Srilakshmi"
     self.assertEqual(rearrange_name(testcase),expected)
Пример #29
0
 def test_basic(self):
     testcase = 'Lovelace, Ada'
     expected = 'Ada Lovelace'
     self.assertEqual(rearrange_name(testcase),expected)
Пример #30
0
 def test_basic(self):
     testcase = "Dib, Tarek"
     expected = "Tarek Dib"
     self.assertEqual(rearrange_name(testcase), expected)