Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

## Instructions: 1. Open the `test_spellcheck.py` file inside the project folder. 2. Import the `pytest` and `spellcheck` modules. 3. Comment out the beta variable using

## Instructions:

1. Open the `test_spellcheck.py` file inside the project folder.

2. Import the `pytest` and `spellcheck` modules.

3. Comment out the beta variable using # symbol for now.

4. Next, complete the `test_length()` and `test_struc()` functions.

These two functions use input_value to check if the functions defined in spellcheck behave correctly.

5. In `test_length()` function, you must add two assert statements.

In each assert statement you first need to call the required function from the spellcheck file that you imported,

and then check against some conditions. For example, the format will be similar to the following against some condition:

```

assert spellcheck.some_function(input_value)

```

- 5.1: Add the first assert statement over `function word_count()` from the main code which asserts that the returned value is less than 10.

- 5.2: Add the second assert statement over `function char_count()` from the main code which asserts that the returned value is less than 50.

6. In the second function `test_struc()`, you must add two assert statements. The first assert statement checks if the first character is in upper case.

The second assert statement checks if the sentence or the string variable passed ends with a dot (.)

- Add the first assert statement over function `first_char()` from the main code.

Now call a built-in function `isupper()` directly over it, such as `function_name.isupper()`.

- `isupper()` function returns True if it is called over an upper-case character and False if called over a lower-case character.

For example, `"A".isupper()` returns `True` and `"a".isupper()` returns `False`.

- Add the second assert statement over the function `last_char()`from the main code and compare it to `. `

7. Save the files.

8. Open the terminal to execute the files.

9. Run the code using the following command (within the project directory):

```

python3 -m pytest test_spellcheck.py

```

10. Both the tests should pass in this case.

'''

Import statements:

1. Import pytest and spellcheck modules

'''

### WRITE IMPORT STATEMENTS HERE

# String variables to be tested

alpha = "Checking the length & structure of the sentence."

beta = "This sentence should fail the test"

# Do not delete this function. You may change the value assigned to input to test different inputs to your test functions.

@pytest.fixture

def input_value():

input = alpha

return input

# First test function test_length()

def test_length(input_value):

""" Tests whether a string has fewer than 10 words and fewer than 50 chars.

[IMPLEMENT ME]

1. Use an assert statement to check the given string has fewer than 10 words

2. Use an assert statement to check the given string has fewer than 50 chars

Args:

input_value: a function that returns a string, which can be configured

in the input_value() function

"""

### WRITE SOLUTION CODE HERE

raise NotImplementedError()

# Second test function test_struc()

def test_struc(input_value):

""" Tests whether a string begins with a capital letter and ends with a period.

[IMPLEMENT ME]

1. Use an assert statement to check the given string begins with a capital letter

2. Use an assert statement to check the given string end with a period ('.')

Args:

input_value: a function that returns a string, which can be configured

in the input_value() function

"""

### WRITE SOLUTION CODE HERE

raise NotImplementedError()

# Run these tests with `python3 -m pytest test_spellcheck.py`

In Python Please!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions