From 04a6c34f6f6a21c93bfe0cb44128ec103b55bb84 Mon Sep 17 00:00:00 2001 From: Bubbler-4 Date: Sat, 10 Feb 2018 15:43:44 +0900 Subject: [PATCH] Update the example fixtures to new style --- examples/python.yml | 131 +++++++++++++++++++++---------------------- examples/python3.yml | 130 +++++++++++++++++++++--------------------- 2 files changed, 128 insertions(+), 133 deletions(-) diff --git a/examples/python.yml b/examples/python.yml index 0287ecc2..8b7abef6 100644 --- a/examples/python.yml +++ b/examples/python.yml @@ -27,20 +27,20 @@ cw-2: # NOTE: You can use Test or test, whichever you prefer. # Use "describe" to label your test suite. - Test.describe("two_oldest_ages:") - - # Use "it" to identify the conditions you are testing for - Test.it("should return the second oldest age first") - # using assert_equals will report the invalid values to the user - Test.assert_equals(results1[0], 45) - # using expect will just give a user a generic error message, unless you provide a message - Test.expect(results2[0] == 18, "Number is not the second oldest") - - # its best practice to test for multiple groups of tests, using it calls. - Test.it("should return the oldest age last") - - Test.assert_equals(results1[1], 87) - Test.expect(results2[1] == 83, "Number is not the oldest") + @Test.describe("Two Oldest Ages") + def describe1(): + # Use "it" to identify the conditions you are testing for + @Test.it("should return the second oldest age first") + def it1(): + # using assert_equals will report the invalid values to the user + Test.assert_equals(results1[0], 45) + # using expect will just give a user a generic error message, unless you provide a message + Test.expect(results2[0] == 18, "Number is not the second oldest") + # its best practice to test for multiple groups of tests, using it calls. + @Test.it("should return the oldest age last") + def it2(): + Test.assert_equals(results1[1], 87) + Test.expect(results2[1] == 83, "Number is not the oldest") bug fixes: initial: |- @@ -53,21 +53,20 @@ cw-2: fixture: |- # Use "describe" to define the test suite - test.describe('add method') - - # Use "it" to indicate a condition you are testing for - test.it('should add both arguments and return') - - # "assert_equals" will return information about what values were - # expect if the assertion fails. This can be very useful to other - # users trying to pass the kata. - test.assert_equals(add(1,2), 3) - - # "expect" is a lower level assertion that will allow you to test - # anything. It just needs a boolean result. You should pass a message - # as the second parameter so that if the assertion fails the user - # will be giving some useful information. - test.expect(add(1,1) == 2, "add(1,1) should == 2") + @test.describe('add method') + def describe1(): + # Use "it" to indicate a condition you are testing for + @test.it('should add both arguments and return') + def it1(): + # "assert_equals" will return information about what values were + # expect if the assertion fails. This can be very useful to other + # users trying to pass the kata. + test.assert_equals(add(1,2), 3) + # "expect" is a lower level assertion that will allow you to test + # anything. It just needs a boolean result. You should pass a message + # as the second parameter so that if the assertion fails the user + # will be giving some useful information. + test.expect(add(1,1) == 2, "add(1,1) should == 2") refactoring: initial: |- @@ -85,30 +84,29 @@ cw-2: fixture: |- # Use "describe" to define the test suite - test.describe('Person') - - jack = Person('Jack') - - # Use "it" to indicate a condition you are testing for - test.it('should have a name') - - # "assert_equals" will return information about what values were - # expect if the assertion fails. This can be very useful to other - # users trying to pass the kata. - test.assert_equals(jack.name, "Jack") - - - test.it("should greet Jill") - - test.assert_equals(jack.greet("Jill"), "Hello Jill, my name is Jack") - - test.it("should greet other people as well") - - # unlike "assert_equals", "expect" is a lower level assertion that - # takes a boolean to determine if it passes. If it fails it will - # output the message that you give it, or a generic one. It is a good - # idea to provide a custom error message to help users pass the kata - test.expect(jack.greet("Jane") == "Hello Jane, my name is Jack", "Jack apparently is only able to greet Jane") + @test.describe('Person') + def describe1(): + jack = Person('Jack') + + # Use "it" to indicate a condition you are testing for + @test.it('should have a name') + def it1(): + # "assert_equals" will return information about what values were + # expect if the assertion fails. This can be very useful to other + # users trying to pass the kata. + test.assert_equals(jack.name, "Jack") + + @test.it("should greet Jill") + def it2(): + test.assert_equals(jack.greet("Jill"), "Hello Jill, my name is Jack") + + @test.it("should greet other people as well") + def it3(): + # unlike "assert_equals", "expect" is a lower level assertion that + # takes a boolean to determine if it passes. If it fails it will + # output the message that you give it, or a generic one. It is a good + # idea to provide a custom error message to help users pass the kata + test.expect(jack.greet("Jane") == "Hello Jane, my name is Jack", "Jack apparently is only able to greet Jane") reference: initial: |- @@ -119,17 +117,16 @@ cw-2: fixture: |- # Use test.describe (or Test.describe) to describe your test suite - test.describe("websites") - - # Use "it" calls to describe the specific test case - test.it("should have the value 'codewars' inside of it") - - # assert equals will pass if both items equal each other (using ==). If - # the test fails, assert_equals will output a descriptive message indicating - # what the values were expected to be. - test.assert_equals(['codewars'], websites) - - # you can also use the lower level test.expect. If you use test.expect directly then - # you should provide a custom error message, as the default one will be pretty useless - # to users trying to pass the kata. - test.expect(['codewars'] == websites, 'Array does not have correct value') \ No newline at end of file + @test.describe("websites") + def describe1(): + # Use "it" calls to describe the specific test case + @test.it("should have the value 'codewars' inside of it") + def it1(): + # assert equals will pass if both items equal each other (using ==). If + # the test fails, assert_equals will output a descriptive message indicating + # what the values were expected to be. + test.assert_equals(['codewars'], websites) + # you can also use the lower level test.expect. If you use test.expect directly then + # you should provide a custom error message, as the default one will be pretty useless + # to users trying to pass the kata. + test.expect(['codewars'] == websites, 'Array does not have correct value') \ No newline at end of file diff --git a/examples/python3.yml b/examples/python3.yml index 02392cbb..8b7abef6 100644 --- a/examples/python3.yml +++ b/examples/python3.yml @@ -27,20 +27,20 @@ cw-2: # NOTE: You can use Test or test, whichever you prefer. # Use "describe" to label your test suite. - Test.describe("two_oldest_ages:") - - # Use "it" to identify the conditions you are testing for - Test.it("should return the second oldest age first") - # using assert_equals will report the invalid values to the user - Test.assert_equals(results1[0], 45) - # using expect will just give a user a generic error message, unless you provide a message - Test.expect(results2[0] == 18, "Number is not the second oldest") - - # its best practice to test for multiple groups of tests, using it calls. - Test.it("should return the oldest age last") - - Test.assert_equals(results1[1], 87) - Test.expect(results2[1] == 83, "Number is not the oldest") + @Test.describe("Two Oldest Ages") + def describe1(): + # Use "it" to identify the conditions you are testing for + @Test.it("should return the second oldest age first") + def it1(): + # using assert_equals will report the invalid values to the user + Test.assert_equals(results1[0], 45) + # using expect will just give a user a generic error message, unless you provide a message + Test.expect(results2[0] == 18, "Number is not the second oldest") + # its best practice to test for multiple groups of tests, using it calls. + @Test.it("should return the oldest age last") + def it2(): + Test.assert_equals(results1[1], 87) + Test.expect(results2[1] == 83, "Number is not the oldest") bug fixes: initial: |- @@ -53,21 +53,20 @@ cw-2: fixture: |- # Use "describe" to define the test suite - test.describe('add method') - - # Use "it" to indicate a condition you are testing for - test.it('should add both arguments and return') - - # "assert_equals" will return information about what values were - # expect if the assertion fails. This can be very useful to other - # users trying to pass the kata. - test.assert_equals(add(1,2), 3) - - # "expect" is a lower level assertion that will allow you to test - # anything. It just needs a boolean result. You should pass a message - # as the second parameter so that if the assertion fails the user - # will be giving some useful information. - test.expect(add(1,1) == 2, "add(1,1) should == 2") + @test.describe('add method') + def describe1(): + # Use "it" to indicate a condition you are testing for + @test.it('should add both arguments and return') + def it1(): + # "assert_equals" will return information about what values were + # expect if the assertion fails. This can be very useful to other + # users trying to pass the kata. + test.assert_equals(add(1,2), 3) + # "expect" is a lower level assertion that will allow you to test + # anything. It just needs a boolean result. You should pass a message + # as the second parameter so that if the assertion fails the user + # will be giving some useful information. + test.expect(add(1,1) == 2, "add(1,1) should == 2") refactoring: initial: |- @@ -85,29 +84,29 @@ cw-2: fixture: |- # Use "describe" to define the test suite - test.describe('Person') - - jack = Person('Jack') - - # Use "it" to indicate a condition you are testing for - test.it('should have a name') - - # "assert_equals" will return information about what values were - # expect if the assertion fails. This can be very useful to other - # users trying to pass the kata. - test.assert_equals(jack.name, "Jack") - - test.it("should greet Jill") - - test.assert_equals(jack.greet("Jill"), "Hello Jill, my name is Jack") - - test.it("should greet other people as well") - - # unlike "assert_equals", "expect" is a lower level assertion that - # takes a boolean to determine if it passes. If it fails it will - # output the message that you give it, or a generic one. It is a good - # idea to provide a custom error message to help users pass the kata - test.expect(jack.greet("Jane") == "Hello Jane, my name is Jack", "Jack apparently is only able to greet Jane") + @test.describe('Person') + def describe1(): + jack = Person('Jack') + + # Use "it" to indicate a condition you are testing for + @test.it('should have a name') + def it1(): + # "assert_equals" will return information about what values were + # expect if the assertion fails. This can be very useful to other + # users trying to pass the kata. + test.assert_equals(jack.name, "Jack") + + @test.it("should greet Jill") + def it2(): + test.assert_equals(jack.greet("Jill"), "Hello Jill, my name is Jack") + + @test.it("should greet other people as well") + def it3(): + # unlike "assert_equals", "expect" is a lower level assertion that + # takes a boolean to determine if it passes. If it fails it will + # output the message that you give it, or a generic one. It is a good + # idea to provide a custom error message to help users pass the kata + test.expect(jack.greet("Jane") == "Hello Jane, my name is Jack", "Jack apparently is only able to greet Jane") reference: initial: |- @@ -118,17 +117,16 @@ cw-2: fixture: |- # Use test.describe (or Test.describe) to describe your test suite - test.describe("websites") - - # Use "it" calls to describe the specific test case - test.it("should have the value 'codewars' inside of it") - - # assert equals will pass if both items equal each other (using ==). If - # the test fails, assert_equals will output a descriptive message indicating - # what the values were expected to be. - test.assert_equals(['codewars'], websites) - - # you can also use the lower level test.expect. If you use test.expect directly then - # you should provide a custom error message, as the default one will be pretty useless - # to users trying to pass the kata. - test.expect(['codewars'] == websites, 'Array does not have correct value') \ No newline at end of file + @test.describe("websites") + def describe1(): + # Use "it" calls to describe the specific test case + @test.it("should have the value 'codewars' inside of it") + def it1(): + # assert equals will pass if both items equal each other (using ==). If + # the test fails, assert_equals will output a descriptive message indicating + # what the values were expected to be. + test.assert_equals(['codewars'], websites) + # you can also use the lower level test.expect. If you use test.expect directly then + # you should provide a custom error message, as the default one will be pretty useless + # to users trying to pass the kata. + test.expect(['codewars'] == websites, 'Array does not have correct value') \ No newline at end of file