Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:26:00+00:00 2026-05-29T06:26:00+00:00

Say I want to test this module: import osutils def check_ip6(xml): ib_output = osutils.call(‘iconfig

  • 0

Say I want to test this module:

import osutils

def check_ip6(xml):
  ib_output = osutils.call('iconfig ib0')
  # process and validate ib_output (to be unit tested)
  ...

This method is dependent on the environment, because it makes a System call (which expects a specific network interface), so its not callable on a testmachine.

I want to write a Unit test for that method which checks if the processing of ib_output works as expected. Therefore I want to mock osutils.call and let it just return testdata. What is the preferred way to do that? Do I have to do mocking or (monkey) patching?

Example test:

def test_ib6_check():
    from migration import check_ib6
    # how to mock os_utils.call used by the check_ib6-method?
    assert check_ib6(test_xml) == True
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:26:01+00:00Added an answer on May 29, 2026 at 6:26 am

    One solution would be to do from osutils import call and then when patching things replace yourmodule.call with something else before calling test_ib6_check.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a vector: (def data [Hello World Test This]) And I want
If you want to create a custom attribute for MS test (say [Repeat(3)] how
I want to get coverage of let's say CoverageTarget.dll. I have a test.dll to
Let's say I declare a variable: String a = test; And I want to
So say I'm doing TDD and I write a test like this: public void
How do you call a before_filter directly to test it's implementation? Let's say I
Say I have a module with the following: def main(): pass if __name__ ==
Basically, we have this here module that we offer to our users that want
say I have a method I wish to test: public Cars[] GetCars(); I want
Say you want a simple maze on an N by M grid, with one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.