The terminal displayed the message "no tests ran," despite the fact that the script executed without any issues

import pytest
import openpyxl

class test_Read_From_Excel:
    workbook_object = openpyxl.load_workbook("/Users/kartik.tumu/Desktop/Testing Screen Shots/CBS/Selenium/Test Data.xlsx")
    print(workbook_object.sheetnames)

#object of sheet "sh"
    sh = workbook_object["TestData"]

#object of cell "c1" username
    c1 = sh.cell(6,4)

#object of cell "p1" password
    p1 = sh.cell(6,5)

    print(p1.value)
    print(c1.value)

    print('\n Testcase Passed','green')
    print("==================================================")

Hello everyone, I'm relatively new to Python and pytest, and I'm attempting to automate my application using Selenium Webdriver with Pycharm IDE.

Although the above script runs successfully for me, my terminal displays "no tests ran in 1.54s" and collected 0 items. Can someone kindly help me understand what mistake may have been made here? I would greatly appreciate a detailed explanation in simple terms.

Answer №1

You seem to be missing a few key points:

  • pytest specifically runs functions that begin with the word test
  • assertions are necessary in order for a test to be valid

To improve, consider this revision:

import openpyxl


def test_Read_From_Excel():
    workbook_object = openpyxl.load_workbook("/Users/kartik.tumu/Desktop/Testing Screen Shots/CBS/Selenium/Test Data.xlsx")
    print(workbook_object.sheetnames)

    #sheet object "sh"
    sh = workbook_object["TestData"]

    #cell object "c1" for username
    c1 = sh.cell(6,4)

    #cell object "p1" for password
    p1 = sh.cell(6,5)

    print(p1.value)
    print(c1.value)

    assert c1.value == 42

I included just one assertion here, but you should customize the assertions to fit your actual testing needs. It's advisable to avoid using print statements within tests.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieving HTML source code using PyGTK WebKit

Can anyone help me with this issue I am facing in my code? When I try to get the HTML source code of the current page, all I get is 'GString at 0x8875130'. How can I convert this into actual text that contains HTML? import gi gi.require_version( ...

Obtaining cookies through HTTP requests

Each time I attempt to access Tor sites through the .cab web proxy using a browser, I am greeted by a disclaimer from the .cab proxy. After clicking a button on the disclaimer, I finally gain entry to the actual .onion site. It seems like the site relies o ...

Calculate the total sum of values in a pandas column while eliminating any duplicated values

Looking to sum the values in column 'g' of a data frame and remove duplicate rows, here is an example: a b c d e f g 6 2011 1 1 0 0 0 6 2011 1 1 0 0 0 6 2011 1 1 0 0 7 6 2011 1 1 ...

The function $.ajax({}) is not recognized in the Django framework

I have been searching for a solution to this specific problem, but none of the related questions I found were able to help. There must be another reason why it's not working, but I'm finding it difficult to pinpoint the issue. Here is the code sn ...

I am constantly encountering the issue where I receive the error message: Element cannot be found: {"method":"css selector","selector":".user-profile-link"}

For some reason, I am encountering an error message that says: Unable to locate element: {"method":"css selector","selector":".user-profile-link"} - Everything seems to be working fine except for this issue and despite my efforts to find a solution, I ha ...

Struggling with saving a .png file using Python

Can anyone assist me with writing a .png file retrieved from the web using Python? with open(fileName, 'w+') as f: f.write(data) I encountered an error stating 'ascii' codec can't encode character u'\ufffd' ...

Combining elements in a list while maintaining the original format

Here's the scenario: I've got a list that goes something like this: list = ["a","b","c", etc] My goal is to merge the elements together while preserving the original structure. Thus, the desired outcome should resem ...

Python Tutorial: Iterating Over Two Lists Using a For Loop

I am working with two lists. one=["first","second"] two=[1,2] for o in one: for t in two: print(o) print(t) The initial output is as follows: first 1 first 2 second 1 second 2 The desired correct output should be: first 1 2 second ...

Executing loop sequentially in Python

I am currently dealing with a block of code that is intended to crawl through websites of infinite height, like Facebook. The Python selenium script I have written requests the page's javascript to scroll down in order to load more content. However, d ...

Having trouble with Flask not loading images sent through Ajax POST request

When using ajax to post an image, the code looks something like this: // fileData is canvas.toDataURL(fileType); $.ajax({ type: 'POST', url: 'http://ip/api', data: fileData, contentType: false, processData: false, m ...

Linking a function to multiple labels with the same name - tkinter

I need to create a feature that allows users to generate multiple labels by pressing the "Enter" key: def new_line(event): global Row_n Row_n = Row_n + 1 Choose= tk.Label(frame, text="Choose option", background = "white",fo ...

Requirement for a script to be able to choose values from a drop-down menu

Before selecting the HONDA value in the drop down menu, I need to choose a category. The following code is for selecting the category: <div> <ul class="nav nav-tabs customtabview" role="tablist"> <div class="tab-content customtabcontainer"& ...

Failed to retrieve the article outcome from a search on Google

Hi, I'm currently trying to use BeautifulSoup to scrape the content of a link and extract article dates from spans with the class "f". import requests import json from bs4 import BeautifulSoup headers = {'User-Agent': 'Mozilla/5.0 (Mac ...

Exploring Splitting and Slicing of the Mnist Dataset with the Tensorflow Datasets Loading Technique

I am attempting to import the MNIST dataset and separate it into three distinct datasets: train, test, and validation. The correct syntax for this operation is as follows: (train, test, valid) = tfds.load('mnist', split=['train[:90%]',& ...

Python -- Unable to establish a connection due to exceeding maximum number of retries

Every now and then, I encounter an error while Server A attempts to communicate with Server B: ConnectionError: HTTPConnectionPool(host='some_ip', port=some_port): Max retries exceeded with url: /some_url/ (Caused by : [Errno 111] Connection ref ...

Troubleshooting: PyQt QFileDialog custom proxy filter malfunctioning

This efficient code triggers a QFileDialog that prompts the user to choose a .csv file: def load(self,fileName=None): if not fileName: fileName=fileDialog.getOpenFileName(caption="Load Existing Radio Log",filter="csv (*.csv)")[0] ... ...

Is there a way I can utilize for loops to determine a solution for this problem?

view image here5 I'm struggling to implement this using a for loop. Despite several attempts, I can't seem to get it right. insert code below num_of_times = 5 for x in range(1, num_of_times, 5): for y in range(5, i+5): print(y, end= '&ap ...

Is there a way to efficiently eliminate any unnecessary spaces, tabs, line breaks, and other unwanted characters from an input in order to sanitize a Python stdin input?

After numerous attempts with different variations of the code, I still have not been able to successfully clean up unstructured data entered by the user like this: "4231, 312 1231212,12 1 23 123,12,3,123 123 1,2, 3123" I am aiming to transform it ...

Is it possible to generate prime numbers in Python using generators?

In an attempt to calculate prime numbers using Python, I've come up with this basic function: def isPrime(number): if number == 2: return True elif number > 1 and number % 2 != 0: for current in range(3, number): ...

Django AJAX for implementing a unique Like button

I've been attempting to implement a like button using Ajax. In my strain model, I have a field called user_like = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='strains_liked', ...