Question: ## 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!