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 333001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:55:14+00:00 2026-05-12T09:55:14+00:00

In a bit of Python I’m writing (a command line and filter testing tool:

  • 0

In a bit of Python I’m writing (a command line and filter testing tool: claft) I wanted a simple way to invoke the built-in test suite (doctest) and I decided on the following:

if 'DOCTEST' in os.environ and os.environ['DOCTEST']==sys.argv[0]:
    _runDocTests()
    sys.exit()

Thus if the DOCTEST variable is set for some other program I’ll just ignore it. In fact my test for this is just: DOCTEST=./claft ./claft or if I want to be verbose I can use: DOCTEST=./claft VERBOSE=1 ./claft So even if I leave DOCTEST=./claft in my environment the test code will only run when I invoke my program from within its own directory. If I switch to one of my test suites and invoke it using a relative PATH then I’m safe from inadvertently triggering this function.

Has anyone else used this sort of convention?

What are other suggestions or best practices for avoiding conflicts among environment variable names? For providing “hidden” access to test harness functionality?

(Also, if anyone wants to play with claft please feel free to give it a spin. It’s pretty ugly code for now, and is barely a proof of concept. But it is minimally functional. It’s also been a nice way to teach myself how to use Mercurial and bitbucket. The wiki and issue tracking are the best places to post feedback about claft).

  • 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-12T09:55:14+00:00Added an answer on May 12, 2026 at 9:55 am

    Since you’re already doing command-line parsing, why not just add a --selftest option? You won’t have to worry about any conflicts that way, and invocation will be easier.

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

Sidebar

Ask A Question

Stats

  • Questions 174k
  • Answers 174k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I suggest you write out a log file from the… May 12, 2026 at 2:58 pm
  • Editorial Team
    Editorial Team added an answer This code is working properly. Please have a look if… May 12, 2026 at 2:58 pm
  • Editorial Team
    Editorial Team added an answer If the file doesn't need to be human-readable, then serializing… May 12, 2026 at 2:58 pm

Related Questions

In a bit of Python I'm writing (a command line and filter testing tool:
I'm pretty proficient in PHP, but want to try something new. I'm also know
A bit of background: When I save a web page from e.g. IE8 as
I'm dabbling in clojure and am having a little trouble trying to determine the
I have a bit of Python to connect to a database with a switch

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.