Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Improved cw-2.py #571

Merged
merged 14 commits into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 64 additions & 67 deletions examples/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand All @@ -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: |-
Expand All @@ -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: |-
Expand All @@ -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')
@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')
130 changes: 64 additions & 66 deletions examples/python3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand All @@ -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: |-
Expand All @@ -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: |-
Expand All @@ -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')
@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')
Loading