On 19 Jan 2009, at 2:20 AM, Gregory Jefferis wrote: > Hi Adam > > > On 2009-01-19 00:39, "Adam R. Maxwell" <amaxw...@mac.com> wrote: > >> So is anyone else seeing these failures in the unit tests? My guess >> is that this is due to author normalization preferences (I save with >> normalized names). > > No. But you're right about the normalised names pref - that's why. > It does > actually bring up a general issue that I had been wondering about. > Is there > anyway to disable user preferences during the unit tests? We don't > really > want to use any of our personal prefs.
I don't think that's possible, but I don't know too much about unit tests. I'd rather say that the tests should be designed to be independent of the prefs. > > We could obviously remove this test, but it's otherwise perfectly > sensible > and it may not be worth breaking it down into subtests. > > We could also add some logic to the unit test that checks the > BDSKShouldSaveNormalizedAuthorNamesKey and adjusts the test > accordingly, but > that's going to be a pain. That would be wrong, as there is no "right" in this case, that's why it fails. This particular pref is not even guaranteed to be the only one affecting bibtex generation. In fact, it isn't, and moreover: we can't know, because it may change in the future, nobody knows what the prefs will be. > Finally, we could change the pref before running the test. I don't > think > this changes any user preferences, but it could be unset and reset (as > below) for tidiness. > > Thoughts? > > Best, > > Greg > The problem with these particular tests is that they test the wrong thing. They are supposed to test the string parsing, but they test as much the bibtex generation. And in that respect they make assumptions that are baseless, and may well be wrong (in fact, in this case they are wrong). For this particular test it would be better to check the pubFields of the item rather than the bibtex. Christiaan > diff --git a/bibdesk/UnitTests/TestBDSKRISParser.m > b/bibdesk/UnitTests/TestBDSKRISParser.m > index 0df1669..82e2b6a 100644 > --- a/bibdesk/UnitTests/TestBDSKRISParser.m > +++ b/bibdesk/UnitTests/TestBDSKRISParser.m > @@ -69,6 +69,10 @@ static NSString *badRISSingleSpace = @"TY - JOUR > \nT1 - > Julian Steward, American > BibItem *b2 = [[BDSKStringParser > itemsFromString:goodRISNoFinalReturnOrSpace > ofType:BDSKUnknownStringType > error:NULL] lastObject]; > > // These are fairly broad spectrum tests - would probably be > better > to break it down some more. > + // Turn off the normalised author setting if it is ON. > Otherwise we > should have: > + // Author = {Pinkoski, Mark} > + BOOL authorNormalization = [[OFPreferenceWrapper > sharedPreferenceWrapper] > boolForKey:BDSKShouldSaveNormalizedAuthorNamesKey]; > + [[OFPreferenceWrapper sharedPreferenceWrapper] setBool:NO > forKey:BDSKShouldSaveNormalizedAuthorNamesKey]; > > STAssertEqualObjects([b > bibTeXStringWithOptions:BDSKBibTeXOptionDropInternalMask], > > @"@article{cite-key,\n\tAuthor = {Marc Pinkoski},\n\tJournal = > {Histories of > Anthropology Annual},\n\tPages = {172--204},\ > @@ -76,6 +80,7 @@ static NSString *badRISSingleSpace = @"TY - JOUR > \nT1 - > Julian Steward, American > STAssertEqualObjects([b2 > bibTeXStringWithOptions:BDSKBibTeXOptionDropInternalMask], > > @"@article{cite-key,\n\tAuthor = {Marc Pinkoski},\n\tJournal = > {Histories of > Anthropology Annual},\n\tPages = {172--204},\ > @"BibTex format > error for > RIS record, Pinkoski 2008"); > + [[OFPreferenceWrapper sharedPreferenceWrapper] > setBool:authorNormalization > forKey:BDSKShouldSaveNormalizedAuthorNamesKey]; > } > > @end > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Bibdesk-develop mailing list > Bibdesk-develop@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bibdesk-develop ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Bibdesk-develop mailing list Bibdesk-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-develop