[TIP] Testing programs that are intended to be distributed in public repos but which need non-public information in order to work

Doug Latornell doug at sadahome.ca
Sat Aug 27 00:01:48 PDT 2011


On Fri, Aug 26, 2011 at 10:46 PM, Laura Creighton <lac at openend.se> wrote:
> I'm writing an app that I'm hosting publicly on bitbucket.  In order for it
> to work, I need to use my secret password to get into the postgresql
> database at the site I am developing this on, and my PayPal developer
> account id and password, and things of that nature.  But I don't want
> to share this information with the world.
>
> Currently, all this information lives in one file, called settings.py .
> I've asked hg not to track this file.  Instead I have a file called
> settings.notreal.py, which is tracked and is a copy of settings.py
> with the sensitive data replaced with dummy data.  But this means that
> I, and anybody else who wants to hack on the thing needs to know
> that if they make any changes to settings.py they have to make them
> to settings.notreal.py, too.  A trivial python script can generate
> one from the other, the problem is in remembering to do so before you
> make your commit, etc. so that your commit messages i.e 'fix for failing test
> ABC' aren't complete lies, because they leave out the actual fix.
>
> This must be a common situation, with a well understood solution, but
> my Google-fu apparantly isn't up to finding the correct keywords to
> search for.  Maybe the whole approach of having 2 files is wrong, and
> that is why I am not finding anything.  So what do people do?  And
> what url should I read to figure out how to do it too?

I use a Mercurial queue to patch the real credentials into a tracked
file that has all of their values set to None. Mercurial won't let you
push while a queue patch is applied unless you use --force, so  the
likelihood of accidentally pushing real credential values is greatly
reduced. The downside is that you have to juggle your patch queue if
you use mq for anything else in your workflow.

Doug

>
> Laura
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>



More information about the testing-in-python mailing list